import java.util.Scanner;
class Main {
	public void kami() {
		Scanner sc = new Scanner(System.in);
		
		int H = sc.nextInt();
		int W = sc.nextInt();
		int H2 = H;
		int W2 = W;
		int H3 = H - 2;
		while(H != 0 || W != 0){
			while(0 < H){
				if(H == 1 || H == H2){
					for(int i = 1; i <= W; i++){
						System.out.print("#");
					}
					System.out.println();
				}else{
					
					while(0 < H3){
						System.out.print("#");
						for(int i = 1; i <= W2 - 2; i++){
							System.out.print(".");
						}
						System.out.println("#");
						H3--;
					}
					
				}
				H--;
				
			}
			System.out.println();
			H = sc.nextInt();
			W = sc.nextInt();
			H2 = H;
			W2 = W;
			H3 = H - 2;
		}
		
	}

	public static void main(String[] args) {

		new Main().kami();
	}

} import java.util.Scanner; Scanner java.util class Main {
	public void kami() {
		Scanner sc = new Scanner(System.in);
		
		int H = sc.nextInt();
		int W = sc.nextInt();
		int H2 = H;
		int W2 = W;
		int H3 = H - 2;
		while(H != 0 || W != 0){
			while(0 < H){
				if(H == 1 || H == H2){
					for(int i = 1; i <= W; i++){
						System.out.print("#");
					}
					System.out.println();
				}else{
					
					while(0 < H3){
						System.out.print("#");
						for(int i = 1; i <= W2 - 2; i++){
							System.out.print(".");
						}
						System.out.println("#");
						H3--;
					}
					
				}
				H--;
				
			}
			System.out.println();
			H = sc.nextInt();
			W = sc.nextInt();
			H2 = H;
			W2 = W;
			H3 = H - 2;
		}
		
	}

	public static void main(String[] args) {

		new Main().kami();
	}

} Main public void kami() {
		Scanner sc = new Scanner(System.in);
		
		int H = sc.nextInt();
		int W = sc.nextInt();
		int H2 = H;
		int W2 = W;
		int H3 = H - 2;
		while(H != 0 || W != 0){
			while(0 < H){
				if(H == 1 || H == H2){
					for(int i = 1; i <= W; i++){
						System.out.print("#");
					}
					System.out.println();
				}else{
					
					while(0 < H3){
						System.out.print("#");
						for(int i = 1; i <= W2 - 2; i++){
							System.out.print(".");
						}
						System.out.println("#");
						H3--;
					}
					
				}
				H--;
				
			}
			System.out.println();
			H = sc.nextInt();
			W = sc.nextInt();
			H2 = H;
			W2 = W;
			H3 = H - 2;
		}
		
	} kami {
		Scanner sc = new Scanner(System.in);
		
		int H = sc.nextInt();
		int W = sc.nextInt();
		int H2 = H;
		int W2 = W;
		int H3 = H - 2;
		while(H != 0 || W != 0){
			while(0 < H){
				if(H == 1 || H == H2){
					for(int i = 1; i <= W; i++){
						System.out.print("#");
					}
					System.out.println();
				}else{
					
					while(0 < H3){
						System.out.print("#");
						for(int i = 1; i <= W2 - 2; i++){
							System.out.print(".");
						}
						System.out.println("#");
						H3--;
					}
					
				}
				H--;
				
			}
			System.out.println();
			H = sc.nextInt();
			W = sc.nextInt();
			H2 = H;
			W2 = W;
			H3 = H - 2;
		}
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int H = sc.nextInt(); H sc.nextInt() sc.nextInt sc int W = sc.nextInt(); W sc.nextInt() sc.nextInt sc int H2 = H; H2 H int W2 = W; W2 W int H3 = H - 2; H3 H - 2 H 2 while(H != 0 || W != 0){
			while(0 < H){
				if(H == 1 || H == H2){
					for(int i = 1; i <= W; i++){
						System.out.print("#");
					}
					System.out.println();
				}else{
					
					while(0 < H3){
						System.out.print("#");
						for(int i = 1; i <= W2 - 2; i++){
							System.out.print(".");
						}
						System.out.println("#");
						H3--;
					}
					
				}
				H--;
				
			}
			System.out.println();
			H = sc.nextInt();
			W = sc.nextInt();
			H2 = H;
			W2 = W;
			H3 = H - 2;
		} H != 0 || W != 0 H != 0 H 0 W != 0 W 0 {
			while(0 < H){
				if(H == 1 || H == H2){
					for(int i = 1; i <= W; i++){
						System.out.print("#");
					}
					System.out.println();
				}else{
					
					while(0 < H3){
						System.out.print("#");
						for(int i = 1; i <= W2 - 2; i++){
							System.out.print(".");
						}
						System.out.println("#");
						H3--;
					}
					
				}
				H--;
				
			}
			System.out.println();
			H = sc.nextInt();
			W = sc.nextInt();
			H2 = H;
			W2 = W;
			H3 = H - 2;
		} while(0 < H){
				if(H == 1 || H == H2){
					for(int i = 1; i <= W; i++){
						System.out.print("#");
					}
					System.out.println();
				}else{
					
					while(0 < H3){
						System.out.print("#");
						for(int i = 1; i <= W2 - 2; i++){
							System.out.print(".");
						}
						System.out.println("#");
						H3--;
					}
					
				}
				H--;
				
			} 0 < H 0 H {
				if(H == 1 || H == H2){
					for(int i = 1; i <= W; i++){
						System.out.print("#");
					}
					System.out.println();
				}else{
					
					while(0 < H3){
						System.out.print("#");
						for(int i = 1; i <= W2 - 2; i++){
							System.out.print(".");
						}
						System.out.println("#");
						H3--;
					}
					
				}
				H--;
				
			} if(H == 1 || H == H2){
					for(int i = 1; i <= W; i++){
						System.out.print("#");
					}
					System.out.println();
				}else{
					
					while(0 < H3){
						System.out.print("#");
						for(int i = 1; i <= W2 - 2; i++){
							System.out.print(".");
						}
						System.out.println("#");
						H3--;
					}
					
				} H == 1 || H == H2 H == 1 H 1 H == H2 H H2 {
					for(int i = 1; i <= W; i++){
						System.out.print("#");
					}
					System.out.println();
				} for(int i = 1; i <= W; i++){
						System.out.print("#");
					} int i = 1; int i = 1; i 1 i <= W i W i++ i++ i {
						System.out.print("#");
					} {
						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 {
					
					while(0 < H3){
						System.out.print("#");
						for(int i = 1; i <= W2 - 2; i++){
							System.out.print(".");
						}
						System.out.println("#");
						H3--;
					}
					
				} while(0 < H3){
						System.out.print("#");
						for(int i = 1; i <= W2 - 2; i++){
							System.out.print(".");
						}
						System.out.println("#");
						H3--;
					} 0 < H3 0 H3 {
						System.out.print("#");
						for(int i = 1; i <= W2 - 2; i++){
							System.out.print(".");
						}
						System.out.println("#");
						H3--;
					} System.out.print("#") System.out.print System.out System System.out "#" for(int i = 1; i <= W2 - 2; i++){
							System.out.print(".");
						} int i = 1; int i = 1; i 1 i <= W2 - 2 i W2 - 2 W2 2 i++ i++ i {
							System.out.print(".");
						} {
							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 "#" H3-- H3 H-- H System.out.println() System.out.println System.out System System.out H = sc.nextInt() H sc.nextInt() sc.nextInt sc W = sc.nextInt() W sc.nextInt() sc.nextInt sc H2 = H H2 H W2 = W W2 W H3 = H - 2 H3 H - 2 H 2 public static void main(String[] args) {

		new Main().kami();
	} main {

		new Main().kami();
	} new Main().kami() new Main().kami new Main() String[] args args
import java.util.Scanner;
class Main {
	public void kami() {
		Scanner sc = new Scanner(System.in);
		
		int H = sc.nextInt();
		int W = sc.nextInt();
		int H2 = H;
		int W2 = W;
		int H3 = H - 2;
		while(H != 0 || W != 0){
			while(0 < H){
				if(H == 1 || H == H2){
					for(int i = 1; i <= W; i++){
						System.out.print("#");
					}
					System.out.println();
				}else{
					
					while(0 < H3){
						System.out.print("#");
						for(int i = 1; i <= W2 - 2; i++){
							System.out.print(".");
						}
						System.out.println("#");
						H3--;
					}
					
				}
				H--;
				
			}
			System.out.println();
			H = sc.nextInt();
			W = sc.nextInt();
			H2 = H;
			W2 = W;
			H3 = H - 2;
		}
		
	}

	public static void main(String[] args) {

		new Main().kami();
	}

}