import java.io.*;

class Main {
	public static void main(String[] args){
		try {
			BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
			

			 while(true){
			 String[] line = br.readLine().split(" ");
			int H = Integer.parseInt(line[0]);
			int W = Integer.parseInt(line[1]);
			if(H == 0 && W == 0) break;
			 for(int a = 1; a <= H; a++){
			 		for(int b = 1; b <=W; b++){
			 			if(a == 1 || a == H || b ==1 || b == W){
		 	   				System.out.print("#");
		 	   			} else{
		 	   				System.out.print(".");
		 	   			}
		 	   		}
	 	   			System.out.print("\n");	
	 	   	 }
	 	   	System.out.print("\n");
	 	   	}
	 	   	} catch(Exception e){
	 	}
	 }
} import java.io.*; io.* java class Main {
	public static void main(String[] args){
		try {
			BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
			

			 while(true){
			 String[] line = br.readLine().split(" ");
			int H = Integer.parseInt(line[0]);
			int W = Integer.parseInt(line[1]);
			if(H == 0 && W == 0) break;
			 for(int a = 1; a <= H; a++){
			 		for(int b = 1; b <=W; b++){
			 			if(a == 1 || a == H || b ==1 || b == W){
		 	   				System.out.print("#");
		 	   			} else{
		 	   				System.out.print(".");
		 	   			}
		 	   		}
	 	   			System.out.print("\n");	
	 	   	 }
	 	   	System.out.print("\n");
	 	   	}
	 	   	} catch(Exception e){
	 	}
	 }
} Main public static void main(String[] args){
		try {
			BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
			

			 while(true){
			 String[] line = br.readLine().split(" ");
			int H = Integer.parseInt(line[0]);
			int W = Integer.parseInt(line[1]);
			if(H == 0 && W == 0) break;
			 for(int a = 1; a <= H; a++){
			 		for(int b = 1; b <=W; b++){
			 			if(a == 1 || a == H || b ==1 || b == W){
		 	   				System.out.print("#");
		 	   			} else{
		 	   				System.out.print(".");
		 	   			}
		 	   		}
	 	   			System.out.print("\n");	
	 	   	 }
	 	   	System.out.print("\n");
	 	   	}
	 	   	} catch(Exception e){
	 	}
	 } main {
		try {
			BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
			

			 while(true){
			 String[] line = br.readLine().split(" ");
			int H = Integer.parseInt(line[0]);
			int W = Integer.parseInt(line[1]);
			if(H == 0 && W == 0) break;
			 for(int a = 1; a <= H; a++){
			 		for(int b = 1; b <=W; b++){
			 			if(a == 1 || a == H || b ==1 || b == W){
		 	   				System.out.print("#");
		 	   			} else{
		 	   				System.out.print(".");
		 	   			}
		 	   		}
	 	   			System.out.print("\n");	
	 	   	 }
	 	   	System.out.print("\n");
	 	   	}
	 	   	} catch(Exception e){
	 	}
	 } try {
			BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
			

			 while(true){
			 String[] line = br.readLine().split(" ");
			int H = Integer.parseInt(line[0]);
			int W = Integer.parseInt(line[1]);
			if(H == 0 && W == 0) break;
			 for(int a = 1; a <= H; a++){
			 		for(int b = 1; b <=W; b++){
			 			if(a == 1 || a == H || b ==1 || b == W){
		 	   				System.out.print("#");
		 	   			} else{
		 	   				System.out.print(".");
		 	   			}
		 	   		}
	 	   			System.out.print("\n");	
	 	   	 }
	 	   	System.out.print("\n");
	 	   	}
	 	   	} catch(Exception e){
	 	} catch(Exception e){
	 	} Exception e {
	 	} {
			BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
			

			 while(true){
			 String[] line = br.readLine().split(" ");
			int H = Integer.parseInt(line[0]);
			int W = Integer.parseInt(line[1]);
			if(H == 0 && W == 0) break;
			 for(int a = 1; a <= H; a++){
			 		for(int b = 1; b <=W; b++){
			 			if(a == 1 || a == H || b ==1 || b == W){
		 	   				System.out.print("#");
		 	   			} else{
		 	   				System.out.print(".");
		 	   			}
		 	   		}
	 	   			System.out.print("\n");	
	 	   	 }
	 	   	System.out.print("\n");
	 	   	}
	 	   	} BufferedReader br =new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
			 String[] line = br.readLine().split(" ");
			int H = Integer.parseInt(line[0]);
			int W = Integer.parseInt(line[1]);
			if(H == 0 && W == 0) break;
			 for(int a = 1; a <= H; a++){
			 		for(int b = 1; b <=W; b++){
			 			if(a == 1 || a == H || b ==1 || b == W){
		 	   				System.out.print("#");
		 	   			} else{
		 	   				System.out.print(".");
		 	   			}
		 	   		}
	 	   			System.out.print("\n");	
	 	   	 }
	 	   	System.out.print("\n");
	 	   	} true {
			 String[] line = br.readLine().split(" ");
			int H = Integer.parseInt(line[0]);
			int W = Integer.parseInt(line[1]);
			if(H == 0 && W == 0) break;
			 for(int a = 1; a <= H; a++){
			 		for(int b = 1; b <=W; b++){
			 			if(a == 1 || a == H || b ==1 || b == W){
		 	   				System.out.print("#");
		 	   			} else{
		 	   				System.out.print(".");
		 	   			}
		 	   		}
	 	   			System.out.print("\n");	
	 	   	 }
	 	   	System.out.print("\n");
	 	   	} String[] line = br.readLine().split(" "); line br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int H = Integer.parseInt(line[0]); H Integer.parseInt(line[0]) Integer.parseInt Integer line[0] line 0 int W = Integer.parseInt(line[1]); W Integer.parseInt(line[1]) Integer.parseInt Integer line[1] line 1 if(H == 0 && W == 0) break; H == 0 && W == 0 H == 0 H 0 W == 0 W 0 break; for(int a = 1; a <= H; a++){
			 		for(int b = 1; b <=W; b++){
			 			if(a == 1 || a == H || b ==1 || b == W){
		 	   				System.out.print("#");
		 	   			} else{
		 	   				System.out.print(".");
		 	   			}
		 	   		}
	 	   			System.out.print("\n");	
	 	   	 } int a = 1; int a = 1; a 1 a <= H a H a++ a++ a {
			 		for(int b = 1; b <=W; b++){
			 			if(a == 1 || a == H || b ==1 || b == W){
		 	   				System.out.print("#");
		 	   			} else{
		 	   				System.out.print(".");
		 	   			}
		 	   		}
	 	   			System.out.print("\n");	
	 	   	 } {
			 		for(int b = 1; b <=W; b++){
			 			if(a == 1 || a == H || b ==1 || b == W){
		 	   				System.out.print("#");
		 	   			} else{
		 	   				System.out.print(".");
		 	   			}
		 	   		}
	 	   			System.out.print("\n");	
	 	   	 } for(int b = 1; b <=W; b++){
			 			if(a == 1 || a == H || b ==1 || b == W){
		 	   				System.out.print("#");
		 	   			} else{
		 	   				System.out.print(".");
		 	   			}
		 	   		} int b = 1; int b = 1; b 1 b <=W b W b++ b++ b {
			 			if(a == 1 || a == H || b ==1 || b == W){
		 	   				System.out.print("#");
		 	   			} else{
		 	   				System.out.print(".");
		 	   			}
		 	   		} {
			 			if(a == 1 || a == H || b ==1 || b == W){
		 	   				System.out.print("#");
		 	   			} else{
		 	   				System.out.print(".");
		 	   			}
		 	   		} if(a == 1 || a == H || b ==1 || b == W){
		 	   				System.out.print("#");
		 	   			} else{
		 	   				System.out.print(".");
		 	   			} a == 1 || a == H || b ==1 || b == W b ==1 a == 1 || a == H || b ==1 || b == W a == 1 a 1 a == H a H b ==1 b 1 b == W b W {
		 	   				System.out.print("#");
		 	   			} System.out.print("#") System.out.print System.out System System.out "#" {
		 	   				System.out.print(".");
		 	   			} System.out.print(".") System.out.print System.out System System.out "." System.out.print("\n") System.out.print System.out System System.out "\n" System.out.print("\n") System.out.print System.out System System.out "\n" String[] args args
import java.io.*;

class Main {
	public static void main(String[] args){
		try {
			BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
			

			 while(true){
			 String[] line = br.readLine().split(" ");
			int H = Integer.parseInt(line[0]);
			int W = Integer.parseInt(line[1]);
			if(H == 0 && W == 0) break;
			 for(int a = 1; a <= H; a++){
			 		for(int b = 1; b <=W; b++){
			 			if(a == 1 || a == H || b ==1 || b == W){
		 	   				System.out.print("#");
		 	   			} else{
		 	   				System.out.print(".");
		 	   			}
		 	   		}
	 	   			System.out.print("\n");	
	 	   	 }
	 	   	System.out.print("\n");
	 	   	}
	 	   	} catch(Exception e){
	 	}
	 }
}