import java.io.*;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while (true) {
			String sz_input = br.readLine();
			String[] sz_num = sz_input.split(" ");
			int H = Integer.parseInt(sz_num[0]);
			int W = Integer.parseInt(sz_num[1]);
			
			if (H == 0 && W == 0) break;
			
			for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == (H-1) || x == 0 || x == (W-1)) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			
			System.out.println();
		}
	}
} import java.io.*; io.* java class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while (true) {
			String sz_input = br.readLine();
			String[] sz_num = sz_input.split(" ");
			int H = Integer.parseInt(sz_num[0]);
			int W = Integer.parseInt(sz_num[1]);
			
			if (H == 0 && W == 0) break;
			
			for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == (H-1) || x == 0 || x == (W-1)) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			
			System.out.println();
		}
	}
} Main public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while (true) {
			String sz_input = br.readLine();
			String[] sz_num = sz_input.split(" ");
			int H = Integer.parseInt(sz_num[0]);
			int W = Integer.parseInt(sz_num[1]);
			
			if (H == 0 && W == 0) break;
			
			for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == (H-1) || x == 0 || x == (W-1)) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			
			System.out.println();
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while (true) {
			String sz_input = br.readLine();
			String[] sz_num = sz_input.split(" ");
			int H = Integer.parseInt(sz_num[0]);
			int W = Integer.parseInt(sz_num[1]);
			
			if (H == 0 && W == 0) break;
			
			for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == (H-1) || x == 0 || x == (W-1)) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			
			System.out.println();
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while (true) {
			String sz_input = br.readLine();
			String[] sz_num = sz_input.split(" ");
			int H = Integer.parseInt(sz_num[0]);
			int W = Integer.parseInt(sz_num[1]);
			
			if (H == 0 && W == 0) break;
			
			for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == (H-1) || x == 0 || x == (W-1)) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			
			System.out.println();
		} true {
			String sz_input = br.readLine();
			String[] sz_num = sz_input.split(" ");
			int H = Integer.parseInt(sz_num[0]);
			int W = Integer.parseInt(sz_num[1]);
			
			if (H == 0 && W == 0) break;
			
			for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == (H-1) || x == 0 || x == (W-1)) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			
			System.out.println();
		} String sz_input = br.readLine(); sz_input br.readLine() br.readLine br String[] sz_num = sz_input.split(" "); sz_num sz_input.split(" ") sz_input.split sz_input " " int H = Integer.parseInt(sz_num[0]); H Integer.parseInt(sz_num[0]) Integer.parseInt Integer sz_num[0] sz_num 0 int W = Integer.parseInt(sz_num[1]); W Integer.parseInt(sz_num[1]) Integer.parseInt Integer sz_num[1] sz_num 1 if (H == 0 && W == 0) break; H == 0 && W == 0 H == 0 H 0 W == 0 W 0 break; for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == (H-1) || x == 0 || x == (W-1)) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			} int y = 0; int y = 0; y 0 y < H y H y++ y++ y {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == (H-1) || x == 0 || x == (W-1)) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			} {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == (H-1) || x == 0 || x == (W-1)) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			} for (int x = 0; x < W; x++) {
					if (y == 0 || y == (H-1) || x == 0 || x == (W-1)) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				} int x = 0; int x = 0; x 0 x < W x W x++ x++ x {
					if (y == 0 || y == (H-1) || x == 0 || x == (W-1)) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				} {
					if (y == 0 || y == (H-1) || x == 0 || x == (W-1)) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				} if (y == 0 || y == (H-1) || x == 0 || x == (W-1)) {
						System.out.print("#");
					} else {
						System.out.print(".");
					} y == 0 || y == (H-1) || x == 0 || x == (W-1) x == 0 y == 0 || y == (H-1) || x == 0 || x == (W-1) y == 0 y 0 y == (H-1) y (H-1) H 1 x == 0 x 0 x == (W-1) x (W-1) W 1 {
						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.println() System.out.println System.out System System.out System.out.println() System.out.println System.out System System.out String args[] args
import java.io.*;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while (true) {
			String sz_input = br.readLine();
			String[] sz_num = sz_input.split(" ");
			int H = Integer.parseInt(sz_num[0]);
			int W = Integer.parseInt(sz_num[1]);
			
			if (H == 0 && W == 0) break;
			
			for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == (H-1) || x == 0 || x == (W-1)) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			
			System.out.println();
		}
	}
}