import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a == 0 && b == 0)
				break;
			for (int i = 1; i <= a; i++) {
				for (int c = 1; c <= b; c++) {
				     if ( i == 1 || i == a || c == 1 | c == b ) {
				    	 System.out.printf("#");
				     } else {
				    	 System.out.printf(".");
				     }
				}
				 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);
		while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a == 0 && b == 0)
				break;
			for (int i = 1; i <= a; i++) {
				for (int c = 1; c <= b; c++) {
				     if ( i == 1 || i == a || c == 1 | c == b ) {
				    	 System.out.printf("#");
				     } else {
				    	 System.out.printf(".");
				     }
				}
				 System.out.println();
			}
		    System.out.println();
		}
     }
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a == 0 && b == 0)
				break;
			for (int i = 1; i <= a; i++) {
				for (int c = 1; c <= b; c++) {
				     if ( i == 1 || i == a || c == 1 | c == b ) {
				    	 System.out.printf("#");
				     } else {
				    	 System.out.printf(".");
				     }
				}
				 System.out.println();
			}
		    System.out.println();
		}
     } main {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a == 0 && b == 0)
				break;
			for (int i = 1; i <= a; i++) {
				for (int c = 1; c <= b; c++) {
				     if ( i == 1 || i == a || c == 1 | c == b ) {
				    	 System.out.printf("#");
				     } else {
				    	 System.out.printf(".");
				     }
				}
				 System.out.println();
			}
		    System.out.println();
		}
     } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a == 0 && b == 0)
				break;
			for (int i = 1; i <= a; i++) {
				for (int c = 1; c <= b; c++) {
				     if ( i == 1 || i == a || c == 1 | c == b ) {
				    	 System.out.printf("#");
				     } else {
				    	 System.out.printf(".");
				     }
				}
				 System.out.println();
			}
		    System.out.println();
		} true {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a == 0 && b == 0)
				break;
			for (int i = 1; i <= a; i++) {
				for (int c = 1; c <= b; c++) {
				     if ( i == 1 || i == a || c == 1 | c == b ) {
				    	 System.out.printf("#");
				     } else {
				    	 System.out.printf(".");
				     }
				}
				 System.out.println();
			}
		    System.out.println();
		} int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc if (a == 0 && b == 0)
				break; a == 0 && b == 0 a == 0 a 0 b == 0 b 0 break; for (int i = 1; i <= a; i++) {
				for (int c = 1; c <= b; c++) {
				     if ( i == 1 || i == a || c == 1 | c == b ) {
				    	 System.out.printf("#");
				     } else {
				    	 System.out.printf(".");
				     }
				}
				 System.out.println();
			} int i = 1; int i = 1; i 1 i <= a i a i++ i++ i {
				for (int c = 1; c <= b; c++) {
				     if ( i == 1 || i == a || c == 1 | c == b ) {
				    	 System.out.printf("#");
				     } else {
				    	 System.out.printf(".");
				     }
				}
				 System.out.println();
			} {
				for (int c = 1; c <= b; c++) {
				     if ( i == 1 || i == a || c == 1 | c == b ) {
				    	 System.out.printf("#");
				     } else {
				    	 System.out.printf(".");
				     }
				}
				 System.out.println();
			} for (int c = 1; c <= b; c++) {
				     if ( i == 1 || i == a || c == 1 | c == b ) {
				    	 System.out.printf("#");
				     } else {
				    	 System.out.printf(".");
				     }
				} int c = 1; int c = 1; c 1 c <= b c b c++ c++ c {
				     if ( i == 1 || i == a || c == 1 | c == b ) {
				    	 System.out.printf("#");
				     } else {
				    	 System.out.printf(".");
				     }
				} {
				     if ( i == 1 || i == a || c == 1 | c == b ) {
				    	 System.out.printf("#");
				     } else {
				    	 System.out.printf(".");
				     }
				} if ( i == 1 || i == a || c == 1 | c == b ) {
				    	 System.out.printf("#");
				     } else {
				    	 System.out.printf(".");
				     } i == 1 || i == a || c == 1 | c == b i == 1 || i == a || c == 1 | c == b i == 1 i 1 i == a i a c == 1 | c == b c == 1 c 1 c == b c b {
				    	 System.out.printf("#");
				     } System.out.printf("#") System.out.printf System.out System System.out "#" {
				    	 System.out.printf(".");
				     } System.out.printf(".") System.out.printf 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);
		while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a == 0 && b == 0)
				break;
			for (int i = 1; i <= a; i++) {
				for (int c = 1; c <= b; c++) {
				     if ( i == 1 || i == a || c == 1 | c == b ) {
				    	 System.out.printf("#");
				     } else {
				    	 System.out.printf(".");
				     }
				}
				 System.out.println();
			}
		    System.out.println();
		}
     }
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a == 0 && b == 0)
				break;
			for (int i = 1; i <= a; i++) {
				for (int c = 1; c <= b; c++) {
				     if ( i == 1 || i == a || c == 1 | c == b ) {
				    	 System.out.printf("#");
				     } else {
				    	 System.out.printf(".");
				     }
				}
				 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);
		while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a == 0 && b == 0)
				break;
			for (int i = 1; i <= a; i++) {
				for (int c = 1; c <= b; c++) {
				     if ( i == 1 || i == a || c == 1 | c == b ) {
				    	 System.out.printf("#");
				     } else {
				    	 System.out.printf(".");
				     }
				}
				 System.out.println();
			}
		    System.out.println();
		}
     }
}
