import java.io.*;

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

	while(true){
	 String[] str = br.readLine().split(" ");
	 int H = Integer.parseInt(str [0]);
	 int W = Integer.parseInt(str [1]);

		if(H == 0 || W == 0){
		 break;
		}else{
			for(int i = 0; i < H; i++){
			 	if(i == 0 || i == H-1){
					for(int n = 0; n < W; n++){
				 	 sb.append("#");
					}
				}else{
				sb.append("#");
					for(int j = 1; j < W-1; j++){
					 sb.append(".");
					}
				sb.append("#");
				}
			 sb.append("\n");
			}
		}
	sb.append("\n");
	}
System.out.print(sb);

}catch(IOException e){
System.out.println(e);
}
}
} import java.io.*; io.* java public class Main{
public static void main(String[] args){
try{
 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 StringBuilder sb = new StringBuilder();

	while(true){
	 String[] str = br.readLine().split(" ");
	 int H = Integer.parseInt(str [0]);
	 int W = Integer.parseInt(str [1]);

		if(H == 0 || W == 0){
		 break;
		}else{
			for(int i = 0; i < H; i++){
			 	if(i == 0 || i == H-1){
					for(int n = 0; n < W; n++){
				 	 sb.append("#");
					}
				}else{
				sb.append("#");
					for(int j = 1; j < W-1; j++){
					 sb.append(".");
					}
				sb.append("#");
				}
			 sb.append("\n");
			}
		}
	sb.append("\n");
	}
System.out.print(sb);

}catch(IOException e){
System.out.println(e);
}
}
} Main public static void main(String[] args){
try{
 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 StringBuilder sb = new StringBuilder();

	while(true){
	 String[] str = br.readLine().split(" ");
	 int H = Integer.parseInt(str [0]);
	 int W = Integer.parseInt(str [1]);

		if(H == 0 || W == 0){
		 break;
		}else{
			for(int i = 0; i < H; i++){
			 	if(i == 0 || i == H-1){
					for(int n = 0; n < W; n++){
				 	 sb.append("#");
					}
				}else{
				sb.append("#");
					for(int j = 1; j < W-1; j++){
					 sb.append(".");
					}
				sb.append("#");
				}
			 sb.append("\n");
			}
		}
	sb.append("\n");
	}
System.out.print(sb);

}catch(IOException e){
System.out.println(e);
}
} main {
try{
 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 StringBuilder sb = new StringBuilder();

	while(true){
	 String[] str = br.readLine().split(" ");
	 int H = Integer.parseInt(str [0]);
	 int W = Integer.parseInt(str [1]);

		if(H == 0 || W == 0){
		 break;
		}else{
			for(int i = 0; i < H; i++){
			 	if(i == 0 || i == H-1){
					for(int n = 0; n < W; n++){
				 	 sb.append("#");
					}
				}else{
				sb.append("#");
					for(int j = 1; j < W-1; j++){
					 sb.append(".");
					}
				sb.append("#");
				}
			 sb.append("\n");
			}
		}
	sb.append("\n");
	}
System.out.print(sb);

}catch(IOException e){
System.out.println(e);
}
} try{
 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 StringBuilder sb = new StringBuilder();

	while(true){
	 String[] str = br.readLine().split(" ");
	 int H = Integer.parseInt(str [0]);
	 int W = Integer.parseInt(str [1]);

		if(H == 0 || W == 0){
		 break;
		}else{
			for(int i = 0; i < H; i++){
			 	if(i == 0 || i == H-1){
					for(int n = 0; n < W; n++){
				 	 sb.append("#");
					}
				}else{
				sb.append("#");
					for(int j = 1; j < W-1; j++){
					 sb.append(".");
					}
				sb.append("#");
				}
			 sb.append("\n");
			}
		}
	sb.append("\n");
	}
System.out.print(sb);

}catch(IOException e){
System.out.println(e);
} catch(IOException e){
System.out.println(e);
} IOException e {
System.out.println(e);
} System.out.println(e) System.out.println System.out System System.out e {
 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 StringBuilder sb = new StringBuilder();

	while(true){
	 String[] str = br.readLine().split(" ");
	 int H = Integer.parseInt(str [0]);
	 int W = Integer.parseInt(str [1]);

		if(H == 0 || W == 0){
		 break;
		}else{
			for(int i = 0; i < H; i++){
			 	if(i == 0 || i == H-1){
					for(int n = 0; n < W; n++){
				 	 sb.append("#");
					}
				}else{
				sb.append("#");
					for(int j = 1; j < W-1; j++){
					 sb.append(".");
					}
				sb.append("#");
				}
			 sb.append("\n");
			}
		}
	sb.append("\n");
	}
System.out.print(sb);

} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() while(true){
	 String[] str = br.readLine().split(" ");
	 int H = Integer.parseInt(str [0]);
	 int W = Integer.parseInt(str [1]);

		if(H == 0 || W == 0){
		 break;
		}else{
			for(int i = 0; i < H; i++){
			 	if(i == 0 || i == H-1){
					for(int n = 0; n < W; n++){
				 	 sb.append("#");
					}
				}else{
				sb.append("#");
					for(int j = 1; j < W-1; j++){
					 sb.append(".");
					}
				sb.append("#");
				}
			 sb.append("\n");
			}
		}
	sb.append("\n");
	} true {
	 String[] str = br.readLine().split(" ");
	 int H = Integer.parseInt(str [0]);
	 int W = Integer.parseInt(str [1]);

		if(H == 0 || W == 0){
		 break;
		}else{
			for(int i = 0; i < H; i++){
			 	if(i == 0 || i == H-1){
					for(int n = 0; n < W; n++){
				 	 sb.append("#");
					}
				}else{
				sb.append("#");
					for(int j = 1; j < W-1; j++){
					 sb.append(".");
					}
				sb.append("#");
				}
			 sb.append("\n");
			}
		}
	sb.append("\n");
	} String[] str = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int H = Integer.parseInt(str [0]); H Integer.parseInt(str [0]) Integer.parseInt Integer str [0] str 0 int W = Integer.parseInt(str [1]); W Integer.parseInt(str [1]) Integer.parseInt Integer str [1] str 1 if(H == 0 || W == 0){
		 break;
		}else{
			for(int i = 0; i < H; i++){
			 	if(i == 0 || i == H-1){
					for(int n = 0; n < W; n++){
				 	 sb.append("#");
					}
				}else{
				sb.append("#");
					for(int j = 1; j < W-1; j++){
					 sb.append(".");
					}
				sb.append("#");
				}
			 sb.append("\n");
			}
		} H == 0 || W == 0 H == 0 H 0 W == 0 W 0 {
		 break;
		} break; {
			for(int i = 0; i < H; i++){
			 	if(i == 0 || i == H-1){
					for(int n = 0; n < W; n++){
				 	 sb.append("#");
					}
				}else{
				sb.append("#");
					for(int j = 1; j < W-1; j++){
					 sb.append(".");
					}
				sb.append("#");
				}
			 sb.append("\n");
			}
		} for(int i = 0; i < H; i++){
			 	if(i == 0 || i == H-1){
					for(int n = 0; n < W; n++){
				 	 sb.append("#");
					}
				}else{
				sb.append("#");
					for(int j = 1; j < W-1; j++){
					 sb.append(".");
					}
				sb.append("#");
				}
			 sb.append("\n");
			} int i = 0; int i = 0; i 0 i < H i H i++ i++ i {
			 	if(i == 0 || i == H-1){
					for(int n = 0; n < W; n++){
				 	 sb.append("#");
					}
				}else{
				sb.append("#");
					for(int j = 1; j < W-1; j++){
					 sb.append(".");
					}
				sb.append("#");
				}
			 sb.append("\n");
			} {
			 	if(i == 0 || i == H-1){
					for(int n = 0; n < W; n++){
				 	 sb.append("#");
					}
				}else{
				sb.append("#");
					for(int j = 1; j < W-1; j++){
					 sb.append(".");
					}
				sb.append("#");
				}
			 sb.append("\n");
			} if(i == 0 || i == H-1){
					for(int n = 0; n < W; n++){
				 	 sb.append("#");
					}
				}else{
				sb.append("#");
					for(int j = 1; j < W-1; j++){
					 sb.append(".");
					}
				sb.append("#");
				} i == 0 || i == H-1 i == 0 i 0 i == H-1 i H-1 H 1 {
					for(int n = 0; n < W; n++){
				 	 sb.append("#");
					}
				} for(int n = 0; n < W; n++){
				 	 sb.append("#");
					} int n = 0; int n = 0; n 0 n < W n W n++ n++ n {
				 	 sb.append("#");
					} {
				 	 sb.append("#");
					} sb.append("#") sb.append sb "#" {
				sb.append("#");
					for(int j = 1; j < W-1; j++){
					 sb.append(".");
					}
				sb.append("#");
				} sb.append("#") sb.append sb "#" for(int j = 1; j < W-1; j++){
					 sb.append(".");
					} int j = 1; int j = 1; j 1 j < W-1 j W-1 W 1 j++ j++ j {
					 sb.append(".");
					} {
					 sb.append(".");
					} sb.append(".") sb.append sb "." sb.append("#") sb.append sb "#" sb.append("\n") sb.append sb "\n" sb.append("\n") sb.append sb "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args public class Main{
public static void main(String[] args){
try{
 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 StringBuilder sb = new StringBuilder();

	while(true){
	 String[] str = br.readLine().split(" ");
	 int H = Integer.parseInt(str [0]);
	 int W = Integer.parseInt(str [1]);

		if(H == 0 || W == 0){
		 break;
		}else{
			for(int i = 0; i < H; i++){
			 	if(i == 0 || i == H-1){
					for(int n = 0; n < W; n++){
				 	 sb.append("#");
					}
				}else{
				sb.append("#");
					for(int j = 1; j < W-1; j++){
					 sb.append(".");
					}
				sb.append("#");
				}
			 sb.append("\n");
			}
		}
	sb.append("\n");
	}
System.out.print(sb);

}catch(IOException e){
System.out.println(e);
}
}
} public class Main{
public static void main(String[] args){
try{
 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 StringBuilder sb = new StringBuilder();

	while(true){
	 String[] str = br.readLine().split(" ");
	 int H = Integer.parseInt(str [0]);
	 int W = Integer.parseInt(str [1]);

		if(H == 0 || W == 0){
		 break;
		}else{
			for(int i = 0; i < H; i++){
			 	if(i == 0 || i == H-1){
					for(int n = 0; n < W; n++){
				 	 sb.append("#");
					}
				}else{
				sb.append("#");
					for(int j = 1; j < W-1; j++){
					 sb.append(".");
					}
				sb.append("#");
				}
			 sb.append("\n");
			}
		}
	sb.append("\n");
	}
System.out.print(sb);

}catch(IOException e){
System.out.println(e);
}
}
} Main
import java.io.*;

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

	while(true){
	 String[] str = br.readLine().split(" ");
	 int H = Integer.parseInt(str [0]);
	 int W = Integer.parseInt(str [1]);

		if(H == 0 || W == 0){
		 break;
		}else{
			for(int i = 0; i < H; i++){
			 	if(i == 0 || i == H-1){
					for(int n = 0; n < W; n++){
				 	 sb.append("#");
					}
				}else{
				sb.append("#");
					for(int j = 1; j < W-1; j++){
					 sb.append(".");
					}
				sb.append("#");
				}
			 sb.append("\n");
			}
		}
	sb.append("\n");
	}
System.out.print(sb);

}catch(IOException e){
System.out.println(e);
}
}
}