import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		StringBuilder output = new StringBuilder();
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			
			if (H == 0 && W == 0)
				break;
			
			for (int i = 0; i < W; i++) {
				output.append("#");
			}
			output.append('\n');
			for (int i = 1; i < H-1; i++) {
				output.append("#");
				for (int j = 1; j < W-1; j++) {
					output.append(".");
				}
				output.append("#");
				output.append('\n');
			}
			for (int i = 0; i < W; i++) {
				output.append("#");
			}
			output.append('\n').append('\n');
		}
		
		System.out.print(output);
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		StringBuilder output = new StringBuilder();
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			
			if (H == 0 && W == 0)
				break;
			
			for (int i = 0; i < W; i++) {
				output.append("#");
			}
			output.append('\n');
			for (int i = 1; i < H-1; i++) {
				output.append("#");
				for (int j = 1; j < W-1; j++) {
					output.append(".");
				}
				output.append("#");
				output.append('\n');
			}
			for (int i = 0; i < W; i++) {
				output.append("#");
			}
			output.append('\n').append('\n');
		}
		
		System.out.print(output);
	}

} Main public static void main(String[] args) {
		StringBuilder output = new StringBuilder();
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			
			if (H == 0 && W == 0)
				break;
			
			for (int i = 0; i < W; i++) {
				output.append("#");
			}
			output.append('\n');
			for (int i = 1; i < H-1; i++) {
				output.append("#");
				for (int j = 1; j < W-1; j++) {
					output.append(".");
				}
				output.append("#");
				output.append('\n');
			}
			for (int i = 0; i < W; i++) {
				output.append("#");
			}
			output.append('\n').append('\n');
		}
		
		System.out.print(output);
	} main {
		StringBuilder output = new StringBuilder();
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			
			if (H == 0 && W == 0)
				break;
			
			for (int i = 0; i < W; i++) {
				output.append("#");
			}
			output.append('\n');
			for (int i = 1; i < H-1; i++) {
				output.append("#");
				for (int j = 1; j < W-1; j++) {
					output.append(".");
				}
				output.append("#");
				output.append('\n');
			}
			for (int i = 0; i < W; i++) {
				output.append("#");
			}
			output.append('\n').append('\n');
		}
		
		System.out.print(output);
	} StringBuilder output = new StringBuilder(); output new StringBuilder() Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while(true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			
			if (H == 0 && W == 0)
				break;
			
			for (int i = 0; i < W; i++) {
				output.append("#");
			}
			output.append('\n');
			for (int i = 1; i < H-1; i++) {
				output.append("#");
				for (int j = 1; j < W-1; j++) {
					output.append(".");
				}
				output.append("#");
				output.append('\n');
			}
			for (int i = 0; i < W; i++) {
				output.append("#");
			}
			output.append('\n').append('\n');
		} true {
			int H = scan.nextInt();
			int W = scan.nextInt();
			
			if (H == 0 && W == 0)
				break;
			
			for (int i = 0; i < W; i++) {
				output.append("#");
			}
			output.append('\n');
			for (int i = 1; i < H-1; i++) {
				output.append("#");
				for (int j = 1; j < W-1; j++) {
					output.append(".");
				}
				output.append("#");
				output.append('\n');
			}
			for (int i = 0; i < W; i++) {
				output.append("#");
			}
			output.append('\n').append('\n');
		} int H = scan.nextInt(); H scan.nextInt() scan.nextInt scan int W = scan.nextInt(); W scan.nextInt() scan.nextInt scan if (H == 0 && W == 0)
				break; H == 0 && W == 0 H == 0 H 0 W == 0 W 0 break; for (int i = 0; i < W; i++) {
				output.append("#");
			} int i = 0; int i = 0; i 0 i < W i W i++ i++ i {
				output.append("#");
			} {
				output.append("#");
			} output.append("#") output.append output "#" output.append('\n') output.append output '\n' for (int i = 1; i < H-1; i++) {
				output.append("#");
				for (int j = 1; j < W-1; j++) {
					output.append(".");
				}
				output.append("#");
				output.append('\n');
			} int i = 1; int i = 1; i 1 i < H-1 i H-1 H 1 i++ i++ i {
				output.append("#");
				for (int j = 1; j < W-1; j++) {
					output.append(".");
				}
				output.append("#");
				output.append('\n');
			} {
				output.append("#");
				for (int j = 1; j < W-1; j++) {
					output.append(".");
				}
				output.append("#");
				output.append('\n');
			} output.append("#") output.append output "#" for (int j = 1; j < W-1; j++) {
					output.append(".");
				} int j = 1; int j = 1; j 1 j < W-1 j W-1 W 1 j++ j++ j {
					output.append(".");
				} {
					output.append(".");
				} output.append(".") output.append output "." output.append("#") output.append output "#" output.append('\n') output.append output '\n' for (int i = 0; i < W; i++) {
				output.append("#");
			} int i = 0; int i = 0; i 0 i < W i W i++ i++ i {
				output.append("#");
			} {
				output.append("#");
			} output.append("#") output.append output "#" output.append('\n').append('\n') output.append('\n').append output.append('\n') output.append output '\n' '\n' System.out.print(output) System.out.print System.out System System.out output String[] args args public class Main {
	public static void main(String[] args) {
		StringBuilder output = new StringBuilder();
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			
			if (H == 0 && W == 0)
				break;
			
			for (int i = 0; i < W; i++) {
				output.append("#");
			}
			output.append('\n');
			for (int i = 1; i < H-1; i++) {
				output.append("#");
				for (int j = 1; j < W-1; j++) {
					output.append(".");
				}
				output.append("#");
				output.append('\n');
			}
			for (int i = 0; i < W; i++) {
				output.append("#");
			}
			output.append('\n').append('\n');
		}
		
		System.out.print(output);
	}

} public class Main {
	public static void main(String[] args) {
		StringBuilder output = new StringBuilder();
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			
			if (H == 0 && W == 0)
				break;
			
			for (int i = 0; i < W; i++) {
				output.append("#");
			}
			output.append('\n');
			for (int i = 1; i < H-1; i++) {
				output.append("#");
				for (int j = 1; j < W-1; j++) {
					output.append(".");
				}
				output.append("#");
				output.append('\n');
			}
			for (int i = 0; i < W; i++) {
				output.append("#");
			}
			output.append('\n').append('\n');
		}
		
		System.out.print(output);
	}

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		StringBuilder output = new StringBuilder();
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			
			if (H == 0 && W == 0)
				break;
			
			for (int i = 0; i < W; i++) {
				output.append("#");
			}
			output.append('\n');
			for (int i = 1; i < H-1; i++) {
				output.append("#");
				for (int j = 1; j < W-1; j++) {
					output.append(".");
				}
				output.append("#");
				output.append('\n');
			}
			for (int i = 0; i < W; i++) {
				output.append("#");
			}
			output.append('\n').append('\n');
		}
		
		System.out.print(output);
	}

}