import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int i = 0;
		while (i < 1000) {
			String line = sc.nextLine();
			String[] array = line.split(" ");
			int H = Integer.parseInt(array[0]);
			int W = Integer.parseInt(array[1]);

			if (W == 0 && H == 0) {
				break;

			} else {

				for (int k = 0; k < H; k++) {

					for (int j = 0; j < W; j++) {
						if (k == 0 || k == H - 1) {
							System.out.print("#");

						} else {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								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 sc = new Scanner(System.in);

		int i = 0;
		while (i < 1000) {
			String line = sc.nextLine();
			String[] array = line.split(" ");
			int H = Integer.parseInt(array[0]);
			int W = Integer.parseInt(array[1]);

			if (W == 0 && H == 0) {
				break;

			} else {

				for (int k = 0; k < H; k++) {

					for (int j = 0; j < W; j++) {
						if (k == 0 || k == H - 1) {
							System.out.print("#");

						} else {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							}
						}

					}
					System.out.println();
				}
				System.out.println();
			}
		}

	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int i = 0;
		while (i < 1000) {
			String line = sc.nextLine();
			String[] array = line.split(" ");
			int H = Integer.parseInt(array[0]);
			int W = Integer.parseInt(array[1]);

			if (W == 0 && H == 0) {
				break;

			} else {

				for (int k = 0; k < H; k++) {

					for (int j = 0; j < W; j++) {
						if (k == 0 || k == H - 1) {
							System.out.print("#");

						} else {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							}
						}

					}
					System.out.println();
				}
				System.out.println();
			}
		}

	} main {
		Scanner sc = new Scanner(System.in);

		int i = 0;
		while (i < 1000) {
			String line = sc.nextLine();
			String[] array = line.split(" ");
			int H = Integer.parseInt(array[0]);
			int W = Integer.parseInt(array[1]);

			if (W == 0 && H == 0) {
				break;

			} else {

				for (int k = 0; k < H; k++) {

					for (int j = 0; j < W; j++) {
						if (k == 0 || k == H - 1) {
							System.out.print("#");

						} else {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							}
						}

					}
					System.out.println();
				}
				System.out.println();
			}
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int i = 0; i 0 while (i < 1000) {
			String line = sc.nextLine();
			String[] array = line.split(" ");
			int H = Integer.parseInt(array[0]);
			int W = Integer.parseInt(array[1]);

			if (W == 0 && H == 0) {
				break;

			} else {

				for (int k = 0; k < H; k++) {

					for (int j = 0; j < W; j++) {
						if (k == 0 || k == H - 1) {
							System.out.print("#");

						} else {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							}
						}

					}
					System.out.println();
				}
				System.out.println();
			}
		} i < 1000 i 1000 {
			String line = sc.nextLine();
			String[] array = line.split(" ");
			int H = Integer.parseInt(array[0]);
			int W = Integer.parseInt(array[1]);

			if (W == 0 && H == 0) {
				break;

			} else {

				for (int k = 0; k < H; k++) {

					for (int j = 0; j < W; j++) {
						if (k == 0 || k == H - 1) {
							System.out.print("#");

						} else {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							}
						}

					}
					System.out.println();
				}
				System.out.println();
			}
		} String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc String[] array = line.split(" "); array line.split(" ") line.split line " " int H = Integer.parseInt(array[0]); H Integer.parseInt(array[0]) Integer.parseInt Integer array[0] array 0 int W = Integer.parseInt(array[1]); W Integer.parseInt(array[1]) Integer.parseInt Integer array[1] array 1 if (W == 0 && H == 0) {
				break;

			} else {

				for (int k = 0; k < H; k++) {

					for (int j = 0; j < W; j++) {
						if (k == 0 || k == H - 1) {
							System.out.print("#");

						} else {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							}
						}

					}
					System.out.println();
				}
				System.out.println();
			} W == 0 && H == 0 W == 0 W 0 H == 0 H 0 {
				break;

			} break; {

				for (int k = 0; k < H; k++) {

					for (int j = 0; j < W; j++) {
						if (k == 0 || k == H - 1) {
							System.out.print("#");

						} else {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							}
						}

					}
					System.out.println();
				}
				System.out.println();
			} for (int k = 0; k < H; k++) {

					for (int j = 0; j < W; j++) {
						if (k == 0 || k == H - 1) {
							System.out.print("#");

						} else {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							}
						}

					}
					System.out.println();
				} int k = 0; int k = 0; k 0 k < H k H k++ k++ k {

					for (int j = 0; j < W; j++) {
						if (k == 0 || k == H - 1) {
							System.out.print("#");

						} else {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							}
						}

					}
					System.out.println();
				} {

					for (int j = 0; j < W; j++) {
						if (k == 0 || k == H - 1) {
							System.out.print("#");

						} else {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							}
						}

					}
					System.out.println();
				} for (int j = 0; j < W; j++) {
						if (k == 0 || k == H - 1) {
							System.out.print("#");

						} else {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							}
						}

					} int j = 0; int j = 0; j 0 j < W j W j++ j++ j {
						if (k == 0 || k == H - 1) {
							System.out.print("#");

						} else {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							}
						}

					} {
						if (k == 0 || k == H - 1) {
							System.out.print("#");

						} else {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							}
						}

					} if (k == 0 || k == H - 1) {
							System.out.print("#");

						} else {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							}
						} k == 0 || k == H - 1 k == 0 k 0 k == H - 1 k H - 1 H 1 {
							System.out.print("#");

						} System.out.print("#") System.out.print System.out System System.out "#" {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							}
						} if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							} j == 0 || j == W - 1 j == 0 j 0 j == W - 1 j 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 public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int i = 0;
		while (i < 1000) {
			String line = sc.nextLine();
			String[] array = line.split(" ");
			int H = Integer.parseInt(array[0]);
			int W = Integer.parseInt(array[1]);

			if (W == 0 && H == 0) {
				break;

			} else {

				for (int k = 0; k < H; k++) {

					for (int j = 0; j < W; j++) {
						if (k == 0 || k == H - 1) {
							System.out.print("#");

						} else {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							}
						}

					}
					System.out.println();
				}
				System.out.println();
			}
		}

	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int i = 0;
		while (i < 1000) {
			String line = sc.nextLine();
			String[] array = line.split(" ");
			int H = Integer.parseInt(array[0]);
			int W = Integer.parseInt(array[1]);

			if (W == 0 && H == 0) {
				break;

			} else {

				for (int k = 0; k < H; k++) {

					for (int j = 0; j < W; j++) {
						if (k == 0 || k == H - 1) {
							System.out.print("#");

						} else {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							}
						}

					}
					System.out.println();
				}
				System.out.println();
			}
		}

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int i = 0;
		while (i < 1000) {
			String line = sc.nextLine();
			String[] array = line.split(" ");
			int H = Integer.parseInt(array[0]);
			int W = Integer.parseInt(array[1]);

			if (W == 0 && H == 0) {
				break;

			} else {

				for (int k = 0; k < H; k++) {

					for (int j = 0; j < W; j++) {
						if (k == 0 || k == H - 1) {
							System.out.print("#");

						} else {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							}
						}

					}
					System.out.println();
				}
				System.out.println();
			}
		}

	}

}