import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int h = scan.nextInt();
			int w = scan.nextInt();
			if (h == 0 && w == 0) {
				break;
			} else if (3 <= h && h <= 300 && 3 <= w && w <= 300) {
				for (int i = 0; i < w; i++) {
					System.out.print("#");
				}
				System.out.println("");
				for (int j = 0; j < h - 2; j++) {
					System.out.print("#");
					for (int k = 0; k < w - 2; k++) {
						System.out.print(".");
					}
					System.out.println("#");
				}
				for (int l = 0; l < w; l++) {
					System.out.print("#");
				}
				System.out.println("");
			}
System.out.println("");

		}

	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int h = scan.nextInt();
			int w = scan.nextInt();
			if (h == 0 && w == 0) {
				break;
			} else if (3 <= h && h <= 300 && 3 <= w && w <= 300) {
				for (int i = 0; i < w; i++) {
					System.out.print("#");
				}
				System.out.println("");
				for (int j = 0; j < h - 2; j++) {
					System.out.print("#");
					for (int k = 0; k < w - 2; k++) {
						System.out.print(".");
					}
					System.out.println("#");
				}
				for (int l = 0; l < w; l++) {
					System.out.print("#");
				}
				System.out.println("");
			}
System.out.println("");

		}

	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int h = scan.nextInt();
			int w = scan.nextInt();
			if (h == 0 && w == 0) {
				break;
			} else if (3 <= h && h <= 300 && 3 <= w && w <= 300) {
				for (int i = 0; i < w; i++) {
					System.out.print("#");
				}
				System.out.println("");
				for (int j = 0; j < h - 2; j++) {
					System.out.print("#");
					for (int k = 0; k < w - 2; k++) {
						System.out.print(".");
					}
					System.out.println("#");
				}
				for (int l = 0; l < w; l++) {
					System.out.print("#");
				}
				System.out.println("");
			}
System.out.println("");

		}

	} main {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int h = scan.nextInt();
			int w = scan.nextInt();
			if (h == 0 && w == 0) {
				break;
			} else if (3 <= h && h <= 300 && 3 <= w && w <= 300) {
				for (int i = 0; i < w; i++) {
					System.out.print("#");
				}
				System.out.println("");
				for (int j = 0; j < h - 2; j++) {
					System.out.print("#");
					for (int k = 0; k < w - 2; k++) {
						System.out.print(".");
					}
					System.out.println("#");
				}
				for (int l = 0; l < w; l++) {
					System.out.print("#");
				}
				System.out.println("");
			}
System.out.println("");

		}

	} 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;
			} else if (3 <= h && h <= 300 && 3 <= w && w <= 300) {
				for (int i = 0; i < w; i++) {
					System.out.print("#");
				}
				System.out.println("");
				for (int j = 0; j < h - 2; j++) {
					System.out.print("#");
					for (int k = 0; k < w - 2; k++) {
						System.out.print(".");
					}
					System.out.println("#");
				}
				for (int l = 0; l < w; l++) {
					System.out.print("#");
				}
				System.out.println("");
			}
System.out.println("");

		} true {
			int h = scan.nextInt();
			int w = scan.nextInt();
			if (h == 0 && w == 0) {
				break;
			} else if (3 <= h && h <= 300 && 3 <= w && w <= 300) {
				for (int i = 0; i < w; i++) {
					System.out.print("#");
				}
				System.out.println("");
				for (int j = 0; j < h - 2; j++) {
					System.out.print("#");
					for (int k = 0; k < w - 2; k++) {
						System.out.print(".");
					}
					System.out.println("#");
				}
				for (int l = 0; l < w; l++) {
					System.out.print("#");
				}
				System.out.println("");
			}
System.out.println("");

		} 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;
			} else if (3 <= h && h <= 300 && 3 <= w && w <= 300) {
				for (int i = 0; i < w; i++) {
					System.out.print("#");
				}
				System.out.println("");
				for (int j = 0; j < h - 2; j++) {
					System.out.print("#");
					for (int k = 0; k < w - 2; k++) {
						System.out.print(".");
					}
					System.out.println("#");
				}
				for (int l = 0; l < w; l++) {
					System.out.print("#");
				}
				System.out.println("");
			} h == 0 && w == 0 h == 0 h 0 w == 0 w 0 {
				break;
			} break; if (3 <= h && h <= 300 && 3 <= w && w <= 300) {
				for (int i = 0; i < w; i++) {
					System.out.print("#");
				}
				System.out.println("");
				for (int j = 0; j < h - 2; j++) {
					System.out.print("#");
					for (int k = 0; k < w - 2; k++) {
						System.out.print(".");
					}
					System.out.println("#");
				}
				for (int l = 0; l < w; l++) {
					System.out.print("#");
				}
				System.out.println("");
			} 3 <= h && h <= 300 && 3 <= w && w <= 300 3 <= w 3 <= h && h <= 300 && 3 <= w && w <= 300 3 <= h 3 h h <= 300 h 300 3 <= w 3 w w <= 300 w 300 {
				for (int i = 0; i < w; i++) {
					System.out.print("#");
				}
				System.out.println("");
				for (int j = 0; j < h - 2; j++) {
					System.out.print("#");
					for (int k = 0; k < w - 2; k++) {
						System.out.print(".");
					}
					System.out.println("#");
				}
				for (int l = 0; l < w; l++) {
					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 "" for (int j = 0; j < h - 2; j++) {
					System.out.print("#");
					for (int k = 0; k < w - 2; k++) {
						System.out.print(".");
					}
					System.out.println("#");
				} int j = 0; int j = 0; j 0 j < h - 2 j h - 2 h 2 j++ j++ j {
					System.out.print("#");
					for (int k = 0; k < w - 2; k++) {
						System.out.print(".");
					}
					System.out.println("#");
				} {
					System.out.print("#");
					for (int k = 0; k < w - 2; k++) {
						System.out.print(".");
					}
					System.out.println("#");
				} System.out.print("#") System.out.print System.out System System.out "#" for (int k = 0; k < w - 2; k++) {
						System.out.print(".");
					} int k = 0; int k = 0; k 0 k < w - 2 k w - 2 w 2 k++ k++ k {
						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 "#" for (int l = 0; l < w; l++) {
					System.out.print("#");
				} int l = 0; int l = 0; l 0 l < w l w l++ l++ l {
					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 "" System.out.println("") System.out.println System.out System System.out "" String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int h = scan.nextInt();
			int w = scan.nextInt();
			if (h == 0 && w == 0) {
				break;
			} else if (3 <= h && h <= 300 && 3 <= w && w <= 300) {
				for (int i = 0; i < w; i++) {
					System.out.print("#");
				}
				System.out.println("");
				for (int j = 0; j < h - 2; j++) {
					System.out.print("#");
					for (int k = 0; k < w - 2; k++) {
						System.out.print(".");
					}
					System.out.println("#");
				}
				for (int l = 0; l < w; l++) {
					System.out.print("#");
				}
				System.out.println("");
			}
System.out.println("");

		}

	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int h = scan.nextInt();
			int w = scan.nextInt();
			if (h == 0 && w == 0) {
				break;
			} else if (3 <= h && h <= 300 && 3 <= w && w <= 300) {
				for (int i = 0; i < w; i++) {
					System.out.print("#");
				}
				System.out.println("");
				for (int j = 0; j < h - 2; j++) {
					System.out.print("#");
					for (int k = 0; k < w - 2; k++) {
						System.out.print(".");
					}
					System.out.println("#");
				}
				for (int l = 0; l < w; l++) {
					System.out.print("#");
				}
				System.out.println("");
			}
System.out.println("");

		}

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int h = scan.nextInt();
			int w = scan.nextInt();
			if (h == 0 && w == 0) {
				break;
			} else if (3 <= h && h <= 300 && 3 <= w && w <= 300) {
				for (int i = 0; i < w; i++) {
					System.out.print("#");
				}
				System.out.println("");
				for (int j = 0; j < h - 2; j++) {
					System.out.print("#");
					for (int k = 0; k < w - 2; k++) {
						System.out.print(".");
					}
					System.out.println("#");
				}
				for (int l = 0; l < w; l++) {
					System.out.print("#");
				}
				System.out.println("");
			}
System.out.println("");

		}

	}

}