

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		while (true) {

			// ????????¢????????¨?¨????????????\???
			int height = in.nextInt();
			int width = in.nextInt();

			// ??\?????????(0,0)??????????????????
			if (height == 0 && width == 0) {
				break;
			} else {

				// ?????????????????°??????????????????
				for (int count_h = 0; count_h < height; count_h++) {

					if(count_h == 0 || count_h == (height-1)) {

						// ?¨???????????????°??????#?????¨???
						for (int count_w = 0; count_w < width; count_w++) {

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

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

						for (int count_w = 0; count_w < (width-2); count_w++) {

							System.out.print(".");
						}
						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 in = new Scanner(System.in);

		while (true) {

			// ????????¢????????¨?¨????????????\???
			int height = in.nextInt();
			int width = in.nextInt();

			// ??\?????????(0,0)??????????????????
			if (height == 0 && width == 0) {
				break;
			} else {

				// ?????????????????°??????????????????
				for (int count_h = 0; count_h < height; count_h++) {

					if(count_h == 0 || count_h == (height-1)) {

						// ?¨???????????????°??????#?????¨???
						for (int count_w = 0; count_w < width; count_w++) {

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

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

						for (int count_w = 0; count_w < (width-2); count_w++) {

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

					}

					System.out.println();
				}

				// ?????????????????????????????????????????\
				System.out.println();
			}
		}
	}
} Main public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		while (true) {

			// ????????¢????????¨?¨????????????\???
			int height = in.nextInt();
			int width = in.nextInt();

			// ??\?????????(0,0)??????????????????
			if (height == 0 && width == 0) {
				break;
			} else {

				// ?????????????????°??????????????????
				for (int count_h = 0; count_h < height; count_h++) {

					if(count_h == 0 || count_h == (height-1)) {

						// ?¨???????????????°??????#?????¨???
						for (int count_w = 0; count_w < width; count_w++) {

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

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

						for (int count_w = 0; count_w < (width-2); count_w++) {

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

					}

					System.out.println();
				}

				// ?????????????????????????????????????????\
				System.out.println();
			}
		}
	} main {

		Scanner in = new Scanner(System.in);

		while (true) {

			// ????????¢????????¨?¨????????????\???
			int height = in.nextInt();
			int width = in.nextInt();

			// ??\?????????(0,0)??????????????????
			if (height == 0 && width == 0) {
				break;
			} else {

				// ?????????????????°??????????????????
				for (int count_h = 0; count_h < height; count_h++) {

					if(count_h == 0 || count_h == (height-1)) {

						// ?¨???????????????°??????#?????¨???
						for (int count_w = 0; count_w < width; count_w++) {

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

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

						for (int count_w = 0; count_w < (width-2); count_w++) {

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

					}

					System.out.println();
				}

				// ?????????????????????????????????????????\
				System.out.println();
			}
		}
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) while (true) {

			// ????????¢????????¨?¨????????????\???
			int height = in.nextInt();
			int width = in.nextInt();

			// ??\?????????(0,0)??????????????????
			if (height == 0 && width == 0) {
				break;
			} else {

				// ?????????????????°??????????????????
				for (int count_h = 0; count_h < height; count_h++) {

					if(count_h == 0 || count_h == (height-1)) {

						// ?¨???????????????°??????#?????¨???
						for (int count_w = 0; count_w < width; count_w++) {

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

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

						for (int count_w = 0; count_w < (width-2); count_w++) {

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

					}

					System.out.println();
				}

				// ?????????????????????????????????????????\
				System.out.println();
			}
		} true {

			// ????????¢????????¨?¨????????????\???
			int height = in.nextInt();
			int width = in.nextInt();

			// ??\?????????(0,0)??????????????????
			if (height == 0 && width == 0) {
				break;
			} else {

				// ?????????????????°??????????????????
				for (int count_h = 0; count_h < height; count_h++) {

					if(count_h == 0 || count_h == (height-1)) {

						// ?¨???????????????°??????#?????¨???
						for (int count_w = 0; count_w < width; count_w++) {

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

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

						for (int count_w = 0; count_w < (width-2); count_w++) {

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

					}

					System.out.println();
				}

				// ?????????????????????????????????????????\
				System.out.println();
			}
		} int height = in.nextInt(); height in.nextInt() in.nextInt in int width = in.nextInt(); width in.nextInt() in.nextInt in if (height == 0 && width == 0) {
				break;
			} else {

				// ?????????????????°??????????????????
				for (int count_h = 0; count_h < height; count_h++) {

					if(count_h == 0 || count_h == (height-1)) {

						// ?¨???????????????°??????#?????¨???
						for (int count_w = 0; count_w < width; count_w++) {

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

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

						for (int count_w = 0; count_w < (width-2); count_w++) {

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

					}

					System.out.println();
				}

				// ?????????????????????????????????????????\
				System.out.println();
			} height == 0 && width == 0 height == 0 height 0 width == 0 width 0 {
				break;
			} break; {

				// ?????????????????°??????????????????
				for (int count_h = 0; count_h < height; count_h++) {

					if(count_h == 0 || count_h == (height-1)) {

						// ?¨???????????????°??????#?????¨???
						for (int count_w = 0; count_w < width; count_w++) {

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

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

						for (int count_w = 0; count_w < (width-2); count_w++) {

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

					}

					System.out.println();
				}

				// ?????????????????????????????????????????\
				System.out.println();
			} for (int count_h = 0; count_h < height; count_h++) {

					if(count_h == 0 || count_h == (height-1)) {

						// ?¨???????????????°??????#?????¨???
						for (int count_w = 0; count_w < width; count_w++) {

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

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

						for (int count_w = 0; count_w < (width-2); count_w++) {

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

					}

					System.out.println();
				} int count_h = 0; int count_h = 0; count_h 0 count_h < height count_h height count_h++ count_h++ count_h {

					if(count_h == 0 || count_h == (height-1)) {

						// ?¨???????????????°??????#?????¨???
						for (int count_w = 0; count_w < width; count_w++) {

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

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

						for (int count_w = 0; count_w < (width-2); count_w++) {

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

					}

					System.out.println();
				} {

					if(count_h == 0 || count_h == (height-1)) {

						// ?¨???????????????°??????#?????¨???
						for (int count_w = 0; count_w < width; count_w++) {

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

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

						for (int count_w = 0; count_w < (width-2); count_w++) {

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

					}

					System.out.println();
				} if(count_h == 0 || count_h == (height-1)) {

						// ?¨???????????????°??????#?????¨???
						for (int count_w = 0; count_w < width; count_w++) {

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

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

						for (int count_w = 0; count_w < (width-2); count_w++) {

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

					} count_h == 0 || count_h == (height-1) count_h == 0 count_h 0 count_h == (height-1) count_h (height-1) height 1 {

						// ?¨???????????????°??????#?????¨???
						for (int count_w = 0; count_w < width; count_w++) {

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

					} for (int count_w = 0; count_w < width; count_w++) {

							System.out.print("#");
						} int count_w = 0; int count_w = 0; count_w 0 count_w < width count_w width count_w++ count_w++ count_w {

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

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

						for (int count_w = 0; count_w < (width-2); count_w++) {

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

					} System.out.print("#") System.out.print System.out System System.out "#" for (int count_w = 0; count_w < (width-2); count_w++) {

							System.out.print(".");
						} int count_w = 0; int count_w = 0; count_w 0 count_w < (width-2) count_w (width-2) width 2 count_w++ count_w++ count_w {

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

							System.out.print(".");
						} 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 in = new Scanner(System.in);

		while (true) {

			// ????????¢????????¨?¨????????????\???
			int height = in.nextInt();
			int width = in.nextInt();

			// ??\?????????(0,0)??????????????????
			if (height == 0 && width == 0) {
				break;
			} else {

				// ?????????????????°??????????????????
				for (int count_h = 0; count_h < height; count_h++) {

					if(count_h == 0 || count_h == (height-1)) {

						// ?¨???????????????°??????#?????¨???
						for (int count_w = 0; count_w < width; count_w++) {

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

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

						for (int count_w = 0; count_w < (width-2); count_w++) {

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

					}

					System.out.println();
				}

				// ?????????????????????????????????????????\
				System.out.println();
			}
		}
	}
} public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		while (true) {

			// ????????¢????????¨?¨????????????\???
			int height = in.nextInt();
			int width = in.nextInt();

			// ??\?????????(0,0)??????????????????
			if (height == 0 && width == 0) {
				break;
			} else {

				// ?????????????????°??????????????????
				for (int count_h = 0; count_h < height; count_h++) {

					if(count_h == 0 || count_h == (height-1)) {

						// ?¨???????????????°??????#?????¨???
						for (int count_w = 0; count_w < width; count_w++) {

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

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

						for (int count_w = 0; count_w < (width-2); count_w++) {

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

					}

					System.out.println();
				}

				// ?????????????????????????????????????????\
				System.out.println();
			}
		}
	}
} Main


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		while (true) {

			// ????????¢????????¨?¨????????????\???
			int height = in.nextInt();
			int width = in.nextInt();

			// ??\?????????(0,0)??????????????????
			if (height == 0 && width == 0) {
				break;
			} else {

				// ?????????????????°??????????????????
				for (int count_h = 0; count_h < height; count_h++) {

					if(count_h == 0 || count_h == (height-1)) {

						// ?¨???????????????°??????#?????¨???
						for (int count_w = 0; count_w < width; count_w++) {

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

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

						for (int count_w = 0; count_w < (width-2); count_w++) {

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

					}

					System.out.println();
				}

				// ?????????????????????????????????????????\
				System.out.println();
			}
		}
	}
}