import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = 1;
		int w = 1;
		StringBuilder sb = new StringBuilder();
		while (true) {
			h = scan.nextInt();
			w = scan.nextInt();
			if (h != 0 && w != 0) {
				for (int i = 0; i < w; i++) {
					sb.append("#");
				}
				sb.append("\n");
				for ( int j = 0; j < h - 2; j++) {
					sb.append("#");
					for (int i = 0; i < w - 2; i++) {
						sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
				for (int i = 0; i < w && h >= 2; i++) {
					sb.append("#");
				}
				sb.append("\n");
				sb.append("\n");
			}else {
				break;
			}
		}
		System.out.print(sb);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = 1;
		int w = 1;
		StringBuilder sb = new StringBuilder();
		while (true) {
			h = scan.nextInt();
			w = scan.nextInt();
			if (h != 0 && w != 0) {
				for (int i = 0; i < w; i++) {
					sb.append("#");
				}
				sb.append("\n");
				for ( int j = 0; j < h - 2; j++) {
					sb.append("#");
					for (int i = 0; i < w - 2; i++) {
						sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
				for (int i = 0; i < w && h >= 2; i++) {
					sb.append("#");
				}
				sb.append("\n");
				sb.append("\n");
			}else {
				break;
			}
		}
		System.out.print(sb);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = 1;
		int w = 1;
		StringBuilder sb = new StringBuilder();
		while (true) {
			h = scan.nextInt();
			w = scan.nextInt();
			if (h != 0 && w != 0) {
				for (int i = 0; i < w; i++) {
					sb.append("#");
				}
				sb.append("\n");
				for ( int j = 0; j < h - 2; j++) {
					sb.append("#");
					for (int i = 0; i < w - 2; i++) {
						sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
				for (int i = 0; i < w && h >= 2; i++) {
					sb.append("#");
				}
				sb.append("\n");
				sb.append("\n");
			}else {
				break;
			}
		}
		System.out.print(sb);
	} main {
		Scanner scan = new Scanner(System.in);
		int h = 1;
		int w = 1;
		StringBuilder sb = new StringBuilder();
		while (true) {
			h = scan.nextInt();
			w = scan.nextInt();
			if (h != 0 && w != 0) {
				for (int i = 0; i < w; i++) {
					sb.append("#");
				}
				sb.append("\n");
				for ( int j = 0; j < h - 2; j++) {
					sb.append("#");
					for (int i = 0; i < w - 2; i++) {
						sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
				for (int i = 0; i < w && h >= 2; i++) {
					sb.append("#");
				}
				sb.append("\n");
				sb.append("\n");
			}else {
				break;
			}
		}
		System.out.print(sb);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int h = 1; h 1 int w = 1; w 1 StringBuilder sb = new StringBuilder(); sb new StringBuilder() while (true) {
			h = scan.nextInt();
			w = scan.nextInt();
			if (h != 0 && w != 0) {
				for (int i = 0; i < w; i++) {
					sb.append("#");
				}
				sb.append("\n");
				for ( int j = 0; j < h - 2; j++) {
					sb.append("#");
					for (int i = 0; i < w - 2; i++) {
						sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
				for (int i = 0; i < w && h >= 2; i++) {
					sb.append("#");
				}
				sb.append("\n");
				sb.append("\n");
			}else {
				break;
			}
		} true {
			h = scan.nextInt();
			w = scan.nextInt();
			if (h != 0 && w != 0) {
				for (int i = 0; i < w; i++) {
					sb.append("#");
				}
				sb.append("\n");
				for ( int j = 0; j < h - 2; j++) {
					sb.append("#");
					for (int i = 0; i < w - 2; i++) {
						sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
				for (int i = 0; i < w && h >= 2; i++) {
					sb.append("#");
				}
				sb.append("\n");
				sb.append("\n");
			}else {
				break;
			}
		} h = scan.nextInt() h scan.nextInt() scan.nextInt scan w = scan.nextInt() w scan.nextInt() scan.nextInt scan if (h != 0 && w != 0) {
				for (int i = 0; i < w; i++) {
					sb.append("#");
				}
				sb.append("\n");
				for ( int j = 0; j < h - 2; j++) {
					sb.append("#");
					for (int i = 0; i < w - 2; i++) {
						sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
				for (int i = 0; i < w && h >= 2; i++) {
					sb.append("#");
				}
				sb.append("\n");
				sb.append("\n");
			}else {
				break;
			} h != 0 && w != 0 h != 0 h 0 w != 0 w 0 {
				for (int i = 0; i < w; i++) {
					sb.append("#");
				}
				sb.append("\n");
				for ( int j = 0; j < h - 2; j++) {
					sb.append("#");
					for (int i = 0; i < w - 2; i++) {
						sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
				for (int i = 0; i < w && h >= 2; i++) {
					sb.append("#");
				}
				sb.append("\n");
				sb.append("\n");
			} for (int i = 0; i < w; i++) {
					sb.append("#");
				} int i = 0; int i = 0; i 0 i < w i w i++ i++ i {
					sb.append("#");
				} {
					sb.append("#");
				} sb.append("#") sb.append sb "#" sb.append("\n") sb.append sb "\n" for ( int j = 0; j < h - 2; j++) {
					sb.append("#");
					for (int i = 0; i < w - 2; i++) {
						sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				} int j = 0; int j = 0; j 0 j < h - 2 j h - 2 h 2 j++ j++ j {
					sb.append("#");
					for (int i = 0; i < w - 2; i++) {
						sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				} {
					sb.append("#");
					for (int i = 0; i < w - 2; i++) {
						sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				} sb.append("#") sb.append sb "#" for (int i = 0; i < w - 2; i++) {
						sb.append(".");
					} int i = 0; int i = 0; i 0 i < w - 2 i w - 2 w 2 i++ i++ i {
						sb.append(".");
					} {
						sb.append(".");
					} sb.append(".") sb.append sb "." sb.append("#") sb.append sb "#" sb.append("\n") sb.append sb "\n" for (int i = 0; i < w && h >= 2; i++) {
					sb.append("#");
				} int i = 0; int i = 0; i 0 i < w && h >= 2 i < w i w h >= 2 h 2 i++ i++ i {
					sb.append("#");
				} {
					sb.append("#");
				} sb.append("#") sb.append sb "#" sb.append("\n") sb.append sb "\n" sb.append("\n") sb.append sb "\n" {
				break;
			} break; System.out.print(sb) System.out.print System.out System System.out sb String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = 1;
		int w = 1;
		StringBuilder sb = new StringBuilder();
		while (true) {
			h = scan.nextInt();
			w = scan.nextInt();
			if (h != 0 && w != 0) {
				for (int i = 0; i < w; i++) {
					sb.append("#");
				}
				sb.append("\n");
				for ( int j = 0; j < h - 2; j++) {
					sb.append("#");
					for (int i = 0; i < w - 2; i++) {
						sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
				for (int i = 0; i < w && h >= 2; i++) {
					sb.append("#");
				}
				sb.append("\n");
				sb.append("\n");
			}else {
				break;
			}
		}
		System.out.print(sb);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = 1;
		int w = 1;
		StringBuilder sb = new StringBuilder();
		while (true) {
			h = scan.nextInt();
			w = scan.nextInt();
			if (h != 0 && w != 0) {
				for (int i = 0; i < w; i++) {
					sb.append("#");
				}
				sb.append("\n");
				for ( int j = 0; j < h - 2; j++) {
					sb.append("#");
					for (int i = 0; i < w - 2; i++) {
						sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
				for (int i = 0; i < w && h >= 2; i++) {
					sb.append("#");
				}
				sb.append("\n");
				sb.append("\n");
			}else {
				break;
			}
		}
		System.out.print(sb);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = 1;
		int w = 1;
		StringBuilder sb = new StringBuilder();
		while (true) {
			h = scan.nextInt();
			w = scan.nextInt();
			if (h != 0 && w != 0) {
				for (int i = 0; i < w; i++) {
					sb.append("#");
				}
				sb.append("\n");
				for ( int j = 0; j < h - 2; j++) {
					sb.append("#");
					for (int i = 0; i < w - 2; i++) {
						sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
				for (int i = 0; i < w && h >= 2; i++) {
					sb.append("#");
				}
				sb.append("\n");
				sb.append("\n");
			}else {
				break;
			}
		}
		System.out.print(sb);
	}
}