import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int H, W;

		while (true) {
			H = scanner.nextInt();
			W = scanner.nextInt();

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

			for (int i = 0; i < H; i++) {
				if (i == 0 || i == H - 1) {
					for (int i2 = 0; i2 < W; i2++) {
						System.out.print("#");
					}
				} else {
					for (int i2 = 0; i2 < W; i2++) {
						if (i2 == 0 || i2 == W - 1) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
				}

				System.out.println();
			}

			System.out.println();
		}
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int H, W;

		while (true) {
			H = scanner.nextInt();
			W = scanner.nextInt();

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

			for (int i = 0; i < H; i++) {
				if (i == 0 || i == H - 1) {
					for (int i2 = 0; i2 < W; i2++) {
						System.out.print("#");
					}
				} else {
					for (int i2 = 0; i2 < W; i2++) {
						if (i2 == 0 || i2 == W - 1) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
				}

				System.out.println();
			}

			System.out.println();
		}
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int H, W;

		while (true) {
			H = scanner.nextInt();
			W = scanner.nextInt();

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

			for (int i = 0; i < H; i++) {
				if (i == 0 || i == H - 1) {
					for (int i2 = 0; i2 < W; i2++) {
						System.out.print("#");
					}
				} else {
					for (int i2 = 0; i2 < W; i2++) {
						if (i2 == 0 || i2 == W - 1) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
				}

				System.out.println();
			}

			System.out.println();
		}
	} main {
		Scanner scanner = new Scanner(System.in);
		int H, W;

		while (true) {
			H = scanner.nextInt();
			W = scanner.nextInt();

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

			for (int i = 0; i < H; i++) {
				if (i == 0 || i == H - 1) {
					for (int i2 = 0; i2 < W; i2++) {
						System.out.print("#");
					}
				} else {
					for (int i2 = 0; i2 < W; i2++) {
						if (i2 == 0 || i2 == W - 1) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
				}

				System.out.println();
			}

			System.out.println();
		}
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int H H W; W while (true) {
			H = scanner.nextInt();
			W = scanner.nextInt();

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

			for (int i = 0; i < H; i++) {
				if (i == 0 || i == H - 1) {
					for (int i2 = 0; i2 < W; i2++) {
						System.out.print("#");
					}
				} else {
					for (int i2 = 0; i2 < W; i2++) {
						if (i2 == 0 || i2 == W - 1) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
				}

				System.out.println();
			}

			System.out.println();
		} true {
			H = scanner.nextInt();
			W = scanner.nextInt();

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

			for (int i = 0; i < H; i++) {
				if (i == 0 || i == H - 1) {
					for (int i2 = 0; i2 < W; i2++) {
						System.out.print("#");
					}
				} else {
					for (int i2 = 0; i2 < W; i2++) {
						if (i2 == 0 || i2 == W - 1) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
				}

				System.out.println();
			}

			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; for (int i = 0; i < H; i++) {
				if (i == 0 || i == H - 1) {
					for (int i2 = 0; i2 < W; i2++) {
						System.out.print("#");
					}
				} else {
					for (int i2 = 0; i2 < W; i2++) {
						if (i2 == 0 || i2 == W - 1) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
				}

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

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

				System.out.println();
			} if (i == 0 || i == H - 1) {
					for (int i2 = 0; i2 < W; i2++) {
						System.out.print("#");
					}
				} else {
					for (int i2 = 0; i2 < W; i2++) {
						if (i2 == 0 || i2 == W - 1) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
				} i == 0 || i == H - 1 i == 0 i 0 i == H - 1 i H - 1 H 1 {
					for (int i2 = 0; i2 < W; i2++) {
						System.out.print("#");
					}
				} for (int i2 = 0; i2 < W; i2++) {
						System.out.print("#");
					} int i2 = 0; int i2 = 0; i2 0 i2 < W i2 W i2++ i2++ i2 {
						System.out.print("#");
					} {
						System.out.print("#");
					} System.out.print("#") System.out.print System.out System System.out "#" {
					for (int i2 = 0; i2 < W; i2++) {
						if (i2 == 0 || i2 == W - 1) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
				} for (int i2 = 0; i2 < W; i2++) {
						if (i2 == 0 || i2 == W - 1) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					} int i2 = 0; int i2 = 0; i2 0 i2 < W i2 W i2++ i2++ i2 {
						if (i2 == 0 || i2 == W - 1) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					} {
						if (i2 == 0 || i2 == W - 1) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					} if (i2 == 0 || i2 == W - 1) {
							System.out.print("#");
						} else {
							System.out.print(".");
						} i2 == 0 || i2 == W - 1 i2 == 0 i2 0 i2 == W - 1 i2 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.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int H, W;

		while (true) {
			H = scanner.nextInt();
			W = scanner.nextInt();

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

			for (int i = 0; i < H; i++) {
				if (i == 0 || i == H - 1) {
					for (int i2 = 0; i2 < W; i2++) {
						System.out.print("#");
					}
				} else {
					for (int i2 = 0; i2 < W; i2++) {
						if (i2 == 0 || i2 == W - 1) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
				}

				System.out.println();
			}

			System.out.println();
		}
	}
}