
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		// Scanner scanner = new Scanner("3 5 4 2 0 0 8 8");
		Scanner scanner = new Scanner(System.in);
		int h;
		int w;
		while (true) {
			h = scanner.nextInt();
			w = scanner.nextInt();
			if (h == 0 && w == 0) {
				break;
			}
			lineMaker01(w);
			for (int j = 0; j < h - 2; j++) {
				lineMaker02(w);
			}
			lineMaker01(w);
			System.out.println("");
		}
		//System.out.println("");
	}

	static void lineMaker01(int w) {
		for (int i = 0; i < w; i++) {
			System.out.print("#");
		}
		System.out.println("");
	}

	static void lineMaker02(int w) {
		System.out.print("#");
		for (int i = 0; i < w - 2; i++) {
			System.out.print(".");
		}
		System.out.print("#");
		System.out.println("");
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) {
		// Scanner scanner = new Scanner("3 5 4 2 0 0 8 8");
		Scanner scanner = new Scanner(System.in);
		int h;
		int w;
		while (true) {
			h = scanner.nextInt();
			w = scanner.nextInt();
			if (h == 0 && w == 0) {
				break;
			}
			lineMaker01(w);
			for (int j = 0; j < h - 2; j++) {
				lineMaker02(w);
			}
			lineMaker01(w);
			System.out.println("");
		}
		//System.out.println("");
	}

	static void lineMaker01(int w) {
		for (int i = 0; i < w; i++) {
			System.out.print("#");
		}
		System.out.println("");
	}

	static void lineMaker02(int w) {
		System.out.print("#");
		for (int i = 0; i < w - 2; i++) {
			System.out.print(".");
		}
		System.out.print("#");
		System.out.println("");
	}
} Main public static void main(String[] args) {
		// Scanner scanner = new Scanner("3 5 4 2 0 0 8 8");
		Scanner scanner = new Scanner(System.in);
		int h;
		int w;
		while (true) {
			h = scanner.nextInt();
			w = scanner.nextInt();
			if (h == 0 && w == 0) {
				break;
			}
			lineMaker01(w);
			for (int j = 0; j < h - 2; j++) {
				lineMaker02(w);
			}
			lineMaker01(w);
			System.out.println("");
		}
		//System.out.println("");
	} main {
		// Scanner scanner = new Scanner("3 5 4 2 0 0 8 8");
		Scanner scanner = new Scanner(System.in);
		int h;
		int w;
		while (true) {
			h = scanner.nextInt();
			w = scanner.nextInt();
			if (h == 0 && w == 0) {
				break;
			}
			lineMaker01(w);
			for (int j = 0; j < h - 2; j++) {
				lineMaker02(w);
			}
			lineMaker01(w);
			System.out.println("");
		}
		//System.out.println("");
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int h; h int w; w while (true) {
			h = scanner.nextInt();
			w = scanner.nextInt();
			if (h == 0 && w == 0) {
				break;
			}
			lineMaker01(w);
			for (int j = 0; j < h - 2; j++) {
				lineMaker02(w);
			}
			lineMaker01(w);
			System.out.println("");
		} true {
			h = scanner.nextInt();
			w = scanner.nextInt();
			if (h == 0 && w == 0) {
				break;
			}
			lineMaker01(w);
			for (int j = 0; j < h - 2; j++) {
				lineMaker02(w);
			}
			lineMaker01(w);
			System.out.println("");
		} h = scanner.nextInt() h scanner.nextInt() scanner.nextInt scanner w = scanner.nextInt() w scanner.nextInt() scanner.nextInt scanner if (h == 0 && w == 0) {
				break;
			} h == 0 && w == 0 h == 0 h 0 w == 0 w 0 {
				break;
			} break; lineMaker01(w) lineMaker01 w for (int j = 0; j < h - 2; j++) {
				lineMaker02(w);
			} int j = 0; int j = 0; j 0 j < h - 2 j h - 2 h 2 j++ j++ j {
				lineMaker02(w);
			} {
				lineMaker02(w);
			} lineMaker02(w) lineMaker02 w lineMaker01(w) lineMaker01 w System.out.println("") System.out.println System.out System System.out "" String[] args args static void lineMaker01(int w) {
		for (int i = 0; i < w; i++) {
			System.out.print("#");
		}
		System.out.println("");
	} lineMaker01 {
		for (int i = 0; i < w; i++) {
			System.out.print("#");
		}
		System.out.println("");
	} for (int i = 0; i < w; i++) {
			System.out.print("#");
		} int i = 0; int i = 0; i 0 i < w i w i++ i++ i {
			System.out.print("#");
		} {
			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 "" int w w static void lineMaker02(int w) {
		System.out.print("#");
		for (int i = 0; i < w - 2; i++) {
			System.out.print(".");
		}
		System.out.print("#");
		System.out.println("");
	} lineMaker02 {
		System.out.print("#");
		for (int i = 0; i < w - 2; i++) {
			System.out.print(".");
		}
		System.out.print("#");
		System.out.println("");
	} System.out.print("#") System.out.print System.out System System.out "#" for (int i = 0; i < w - 2; i++) {
			System.out.print(".");
		} int i = 0; int i = 0; i 0 i < w - 2 i w - 2 w 2 i++ i++ i {
			System.out.print(".");
		} {
			System.out.print(".");
		} System.out.print(".") System.out.print System.out System System.out "." System.out.print("#") System.out.print System.out System System.out "#" System.out.println("") System.out.println System.out System System.out "" int w w

import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		// Scanner scanner = new Scanner("3 5 4 2 0 0 8 8");
		Scanner scanner = new Scanner(System.in);
		int h;
		int w;
		while (true) {
			h = scanner.nextInt();
			w = scanner.nextInt();
			if (h == 0 && w == 0) {
				break;
			}
			lineMaker01(w);
			for (int j = 0; j < h - 2; j++) {
				lineMaker02(w);
			}
			lineMaker01(w);
			System.out.println("");
		}
		//System.out.println("");
	}

	static void lineMaker01(int w) {
		for (int i = 0; i < w; i++) {
			System.out.print("#");
		}
		System.out.println("");
	}

	static void lineMaker02(int w) {
		System.out.print("#");
		for (int i = 0; i < w - 2; i++) {
			System.out.print(".");
		}
		System.out.print("#");
		System.out.println("");
	}
}