import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H, W;
		while (true) {
			H = sc.nextInt();
			W = sc.nextInt();

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

		}
	}

	public static void printFrame(int H, int W) {
		for (int i = 0; i < W; i++)
			System.out.print("#");

		System.out.println();

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

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

		}
		for (int i = 0; i < W; i++)
			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 (true) {
			H = sc.nextInt();
			W = sc.nextInt();

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

		}
	}

	public static void printFrame(int H, int W) {
		for (int i = 0; i < W; i++)
			System.out.print("#");

		System.out.println();

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

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

		}
		for (int i = 0; i < W; i++)
			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 (true) {
			H = sc.nextInt();
			W = sc.nextInt();

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

		}
	} main {
		Scanner sc = new Scanner(System.in);
		int H, W;
		while (true) {
			H = sc.nextInt();
			W = sc.nextInt();

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

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

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

		} true {
			H = sc.nextInt();
			W = sc.nextInt();

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

		} H = sc.nextInt() H sc.nextInt() sc.nextInt sc W = sc.nextInt() W sc.nextInt() sc.nextInt sc if (H == 0 && W == 0)
				break; H == 0 && W == 0 H == 0 H 0 W == 0 W 0 break; printFrame(H,W) printFrame H W String[] args args public static void printFrame(int H, int W) {
		for (int i = 0; i < W; i++)
			System.out.print("#");

		System.out.println();

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

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

		}
		for (int i = 0; i < W; i++)
			System.out.print("#");
		
		System.out.println();
		System.out.println();


	} printFrame {
		for (int i = 0; i < W; i++)
			System.out.print("#");

		System.out.println();

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

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

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

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

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

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

		} {
			for (int j = 1; j < W; j++) {
				if (j == 1)
					System.out.print("#");
				else if (j == (W - 1)){
					System.out.println("#");
					break;
				}

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

		} for (int j = 1; j < W; j++) {
				if (j == 1)
					System.out.print("#");
				else if (j == (W - 1)){
					System.out.println("#");
					break;
				}

				System.out.print(".");
			} int j = 1; int j = 1; j 1 j < W j W j++ j++ j {
				if (j == 1)
					System.out.print("#");
				else if (j == (W - 1)){
					System.out.println("#");
					break;
				}

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

				System.out.print(".");
			} if (j == 1)
					System.out.print("#");
				else if (j == (W - 1)){
					System.out.println("#");
					break;
				} j == 1 j 1 System.out.print("#") System.out.print System.out System System.out "#" if (j == (W - 1)){
					System.out.println("#");
					break;
				} j == (W - 1) j (W - 1) W 1 {
					System.out.println("#");
					break;
				} System.out.println("#") System.out.println System.out System System.out "#" break; System.out.print(".") System.out.print System.out System System.out "." 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 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 int H H int W W public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H, W;
		while (true) {
			H = sc.nextInt();
			W = sc.nextInt();

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

		}
	}

	public static void printFrame(int H, int W) {
		for (int i = 0; i < W; i++)
			System.out.print("#");

		System.out.println();

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

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

		}
		for (int i = 0; i < W; i++)
			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 (true) {
			H = sc.nextInt();
			W = sc.nextInt();

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

		}
	}

	public static void printFrame(int H, int W) {
		for (int i = 0; i < W; i++)
			System.out.print("#");

		System.out.println();

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

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

		}
		for (int i = 0; i < W; i++)
			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 (true) {
			H = sc.nextInt();
			W = sc.nextInt();

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

		}
	}

	public static void printFrame(int H, int W) {
		for (int i = 0; i < W; i++)
			System.out.print("#");

		System.out.println();

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

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

		}
		for (int i = 0; i < W; i++)
			System.out.print("#");
		
		System.out.println();
		System.out.println();


	}

}