import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner sc = new Scanner(System.in);
		int i = 0;
		while (i == 0) {
			String line = sc.nextLine();
			String[] x = line.split(" ");
			int H = Integer.parseInt(x[0]);
			int W = Integer.parseInt(x[1]);
			if (H == 0 && W == 0) {
				break;
			}
			String nakami = "";
			String jouge = "##";
			int j = 0;
			while (j < W - 2) {
				nakami += ".";
				jouge += "#";
				j++;
			}
			String yoko = "#" + nakami + "#";
			int k = 0;
			while (k < H) {
				if (k == 0 || k == H - 1) {
					System.out.println(jouge);
				} else {
					System.out.println(yoko);
				}
				k++;
			}
			System.out.println("");

		}
	}

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

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner sc = new Scanner(System.in);
		int i = 0;
		while (i == 0) {
			String line = sc.nextLine();
			String[] x = line.split(" ");
			int H = Integer.parseInt(x[0]);
			int W = Integer.parseInt(x[1]);
			if (H == 0 && W == 0) {
				break;
			}
			String nakami = "";
			String jouge = "##";
			int j = 0;
			while (j < W - 2) {
				nakami += ".";
				jouge += "#";
				j++;
			}
			String yoko = "#" + nakami + "#";
			int k = 0;
			while (k < H) {
				if (k == 0 || k == H - 1) {
					System.out.println(jouge);
				} else {
					System.out.println(yoko);
				}
				k++;
			}
			System.out.println("");

		}
	}

} Main public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner sc = new Scanner(System.in);
		int i = 0;
		while (i == 0) {
			String line = sc.nextLine();
			String[] x = line.split(" ");
			int H = Integer.parseInt(x[0]);
			int W = Integer.parseInt(x[1]);
			if (H == 0 && W == 0) {
				break;
			}
			String nakami = "";
			String jouge = "##";
			int j = 0;
			while (j < W - 2) {
				nakami += ".";
				jouge += "#";
				j++;
			}
			String yoko = "#" + nakami + "#";
			int k = 0;
			while (k < H) {
				if (k == 0 || k == H - 1) {
					System.out.println(jouge);
				} else {
					System.out.println(yoko);
				}
				k++;
			}
			System.out.println("");

		}
	} main {
		// TODO ?????????????????????????????????????????????

		Scanner sc = new Scanner(System.in);
		int i = 0;
		while (i == 0) {
			String line = sc.nextLine();
			String[] x = line.split(" ");
			int H = Integer.parseInt(x[0]);
			int W = Integer.parseInt(x[1]);
			if (H == 0 && W == 0) {
				break;
			}
			String nakami = "";
			String jouge = "##";
			int j = 0;
			while (j < W - 2) {
				nakami += ".";
				jouge += "#";
				j++;
			}
			String yoko = "#" + nakami + "#";
			int k = 0;
			while (k < H) {
				if (k == 0 || k == H - 1) {
					System.out.println(jouge);
				} else {
					System.out.println(yoko);
				}
				k++;
			}
			System.out.println("");

		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int i = 0; i 0 while (i == 0) {
			String line = sc.nextLine();
			String[] x = line.split(" ");
			int H = Integer.parseInt(x[0]);
			int W = Integer.parseInt(x[1]);
			if (H == 0 && W == 0) {
				break;
			}
			String nakami = "";
			String jouge = "##";
			int j = 0;
			while (j < W - 2) {
				nakami += ".";
				jouge += "#";
				j++;
			}
			String yoko = "#" + nakami + "#";
			int k = 0;
			while (k < H) {
				if (k == 0 || k == H - 1) {
					System.out.println(jouge);
				} else {
					System.out.println(yoko);
				}
				k++;
			}
			System.out.println("");

		} i == 0 i 0 {
			String line = sc.nextLine();
			String[] x = line.split(" ");
			int H = Integer.parseInt(x[0]);
			int W = Integer.parseInt(x[1]);
			if (H == 0 && W == 0) {
				break;
			}
			String nakami = "";
			String jouge = "##";
			int j = 0;
			while (j < W - 2) {
				nakami += ".";
				jouge += "#";
				j++;
			}
			String yoko = "#" + nakami + "#";
			int k = 0;
			while (k < H) {
				if (k == 0 || k == H - 1) {
					System.out.println(jouge);
				} else {
					System.out.println(yoko);
				}
				k++;
			}
			System.out.println("");

		} String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc String[] x = line.split(" "); x line.split(" ") line.split line " " int H = Integer.parseInt(x[0]); H Integer.parseInt(x[0]) Integer.parseInt Integer x[0] x 0 int W = Integer.parseInt(x[1]); W Integer.parseInt(x[1]) Integer.parseInt Integer x[1] x 1 if (H == 0 && W == 0) {
				break;
			} H == 0 && W == 0 H == 0 H 0 W == 0 W 0 {
				break;
			} break; String nakami = ""; nakami "" String jouge = "##"; jouge "##" int j = 0; j 0 while (j < W - 2) {
				nakami += ".";
				jouge += "#";
				j++;
			} j < W - 2 j W - 2 W 2 {
				nakami += ".";
				jouge += "#";
				j++;
			} nakami += "." nakami "." jouge += "#" jouge "#" j++ j String yoko = "#" + nakami + "#"; yoko "#" + nakami + "#" "#" + nakami + "#" "#" nakami "#" int k = 0; k 0 while (k < H) {
				if (k == 0 || k == H - 1) {
					System.out.println(jouge);
				} else {
					System.out.println(yoko);
				}
				k++;
			} k < H k H {
				if (k == 0 || k == H - 1) {
					System.out.println(jouge);
				} else {
					System.out.println(yoko);
				}
				k++;
			} if (k == 0 || k == H - 1) {
					System.out.println(jouge);
				} else {
					System.out.println(yoko);
				} k == 0 || k == H - 1 k == 0 k 0 k == H - 1 k H - 1 H 1 {
					System.out.println(jouge);
				} System.out.println(jouge) System.out.println System.out System System.out jouge {
					System.out.println(yoko);
				} System.out.println(yoko) System.out.println System.out System System.out yoko k++ k System.out.println("") System.out.println System.out System System.out "" String[] args args public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner sc = new Scanner(System.in);
		int i = 0;
		while (i == 0) {
			String line = sc.nextLine();
			String[] x = line.split(" ");
			int H = Integer.parseInt(x[0]);
			int W = Integer.parseInt(x[1]);
			if (H == 0 && W == 0) {
				break;
			}
			String nakami = "";
			String jouge = "##";
			int j = 0;
			while (j < W - 2) {
				nakami += ".";
				jouge += "#";
				j++;
			}
			String yoko = "#" + nakami + "#";
			int k = 0;
			while (k < H) {
				if (k == 0 || k == H - 1) {
					System.out.println(jouge);
				} else {
					System.out.println(yoko);
				}
				k++;
			}
			System.out.println("");

		}
	}

} public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner sc = new Scanner(System.in);
		int i = 0;
		while (i == 0) {
			String line = sc.nextLine();
			String[] x = line.split(" ");
			int H = Integer.parseInt(x[0]);
			int W = Integer.parseInt(x[1]);
			if (H == 0 && W == 0) {
				break;
			}
			String nakami = "";
			String jouge = "##";
			int j = 0;
			while (j < W - 2) {
				nakami += ".";
				jouge += "#";
				j++;
			}
			String yoko = "#" + nakami + "#";
			int k = 0;
			while (k < H) {
				if (k == 0 || k == H - 1) {
					System.out.println(jouge);
				} else {
					System.out.println(yoko);
				}
				k++;
			}
			System.out.println("");

		}
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner sc = new Scanner(System.in);
		int i = 0;
		while (i == 0) {
			String line = sc.nextLine();
			String[] x = line.split(" ");
			int H = Integer.parseInt(x[0]);
			int W = Integer.parseInt(x[1]);
			if (H == 0 && W == 0) {
				break;
			}
			String nakami = "";
			String jouge = "##";
			int j = 0;
			while (j < W - 2) {
				nakami += ".";
				jouge += "#";
				j++;
			}
			String yoko = "#" + nakami + "#";
			int k = 0;
			while (k < H) {
				if (k == 0 || k == H - 1) {
					System.out.println(jouge);
				} else {
					System.out.println(yoko);
				}
				k++;
			}
			System.out.println("");

		}
	}

}