import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H, W;
		while (sc.hasNextLine()) {
			String[] str = sc.nextLine().split(" ");
			H = Integer.parseInt(str[0]);
			W = Integer.parseInt(str[1]);
			if (H == 0 && W == 0)
				break;
			for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == H - 1 || x == 0 || x == 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 H, W;
		while (sc.hasNextLine()) {
			String[] str = sc.nextLine().split(" ");
			H = Integer.parseInt(str[0]);
			W = Integer.parseInt(str[1]);
			if (H == 0 && W == 0)
				break;
			for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == H - 1 || x == 0 || x == 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 H, W;
		while (sc.hasNextLine()) {
			String[] str = sc.nextLine().split(" ");
			H = Integer.parseInt(str[0]);
			W = Integer.parseInt(str[1]);
			if (H == 0 && W == 0)
				break;
			for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == H - 1 || x == 0 || x == W - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int H, W;
		while (sc.hasNextLine()) {
			String[] str = sc.nextLine().split(" ");
			H = Integer.parseInt(str[0]);
			W = Integer.parseInt(str[1]);
			if (H == 0 && W == 0)
				break;
			for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == H - 1 || x == 0 || x == 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 H H W; W while (sc.hasNextLine()) {
			String[] str = sc.nextLine().split(" ");
			H = Integer.parseInt(str[0]);
			W = Integer.parseInt(str[1]);
			if (H == 0 && W == 0)
				break;
			for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == H - 1 || x == 0 || x == W - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		} sc.hasNextLine() sc.hasNextLine sc {
			String[] str = sc.nextLine().split(" ");
			H = Integer.parseInt(str[0]);
			W = Integer.parseInt(str[1]);
			if (H == 0 && W == 0)
				break;
			for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == H - 1 || x == 0 || x == W - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		} String[] str = sc.nextLine().split(" "); str sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " H = Integer.parseInt(str[0]) H Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 W = Integer.parseInt(str[1]) W Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 if (H == 0 && W == 0)
				break; H == 0 && W == 0 H == 0 H 0 W == 0 W 0 break; for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == H - 1 || x == 0 || x == W - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			} int y = 0; int y = 0; y 0 y < H y H y++ y++ y {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == H - 1 || x == 0 || x == W - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			} {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == H - 1 || x == 0 || x == W - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			} for (int x = 0; x < W; x++) {
					if (y == 0 || y == H - 1 || x == 0 || x == W - 1)
						System.out.print("#");
					else
						System.out.print(".");
				} int x = 0; int x = 0; x 0 x < W x W x++ x++ x {
					if (y == 0 || y == H - 1 || x == 0 || x == W - 1)
						System.out.print("#");
					else
						System.out.print(".");
				} {
					if (y == 0 || y == H - 1 || x == 0 || x == W - 1)
						System.out.print("#");
					else
						System.out.print(".");
				} if (y == 0 || y == H - 1 || x == 0 || x == W - 1)
						System.out.print("#");
					else
						System.out.print("."); y == 0 || y == H - 1 || x == 0 || x == W - 1 x == 0 y == 0 || y == H - 1 || x == 0 || x == W - 1 y == 0 y 0 y == H - 1 y H - 1 H 1 x == 0 x 0 x == W - 1 x W - 1 W 1 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 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 H, W;
		while (sc.hasNextLine()) {
			String[] str = sc.nextLine().split(" ");
			H = Integer.parseInt(str[0]);
			W = Integer.parseInt(str[1]);
			if (H == 0 && W == 0)
				break;
			for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == H - 1 || x == 0 || x == 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 H, W;
		while (sc.hasNextLine()) {
			String[] str = sc.nextLine().split(" ");
			H = Integer.parseInt(str[0]);
			W = Integer.parseInt(str[1]);
			if (H == 0 && W == 0)
				break;
			for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == H - 1 || x == 0 || x == 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 H, W;
		while (sc.hasNextLine()) {
			String[] str = sc.nextLine().split(" ");
			H = Integer.parseInt(str[0]);
			W = Integer.parseInt(str[1]);
			if (H == 0 && W == 0)
				break;
			for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					if (y == 0 || y == H - 1 || x == 0 || x == W - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
	}

}

