import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int[] h = new int[300], w = new int[300];
		int cnt = 0;
		
		while(true){
			h[cnt] = sc.nextInt();
			w[cnt] = sc.nextInt();
			
			if(w[cnt] == 0 && h[cnt] == 0)
				break;
			
			cnt ++;
		}
		
		for(int i = 0; i < cnt; i++){
			for(int j = 0; j < h[i]; j++){
				for(int k = 0; k < w[i]; k++){
					if(j == 0 || j == h[i] - 1 || k == 0 || k == w[i] - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
} import java.util.*; util.* java class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int[] h = new int[300], w = new int[300];
		int cnt = 0;
		
		while(true){
			h[cnt] = sc.nextInt();
			w[cnt] = sc.nextInt();
			
			if(w[cnt] == 0 && h[cnt] == 0)
				break;
			
			cnt ++;
		}
		
		for(int i = 0; i < cnt; i++){
			for(int j = 0; j < h[i]; j++){
				for(int k = 0; k < w[i]; k++){
					if(j == 0 || j == h[i] - 1 || k == 0 || k == w[i] - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
} Main public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int[] h = new int[300], w = new int[300];
		int cnt = 0;
		
		while(true){
			h[cnt] = sc.nextInt();
			w[cnt] = sc.nextInt();
			
			if(w[cnt] == 0 && h[cnt] == 0)
				break;
			
			cnt ++;
		}
		
		for(int i = 0; i < cnt; i++){
			for(int j = 0; j < h[i]; j++){
				for(int k = 0; k < w[i]; k++){
					if(j == 0 || j == h[i] - 1 || k == 0 || k == w[i] - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println("");
			}
			System.out.println("");
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int[] h = new int[300], w = new int[300];
		int cnt = 0;
		
		while(true){
			h[cnt] = sc.nextInt();
			w[cnt] = sc.nextInt();
			
			if(w[cnt] == 0 && h[cnt] == 0)
				break;
			
			cnt ++;
		}
		
		for(int i = 0; i < cnt; i++){
			for(int j = 0; j < h[i]; j++){
				for(int k = 0; k < w[i]; k++){
					if(j == 0 || j == h[i] - 1 || k == 0 || k == w[i] - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println("");
			}
			System.out.println("");
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int[] h = new int[300] h new int[300] 300 w = new int[300]; w new int[300] 300 int cnt = 0; cnt 0 while(true){
			h[cnt] = sc.nextInt();
			w[cnt] = sc.nextInt();
			
			if(w[cnt] == 0 && h[cnt] == 0)
				break;
			
			cnt ++;
		} true {
			h[cnt] = sc.nextInt();
			w[cnt] = sc.nextInt();
			
			if(w[cnt] == 0 && h[cnt] == 0)
				break;
			
			cnt ++;
		} h[cnt] = sc.nextInt() h[cnt] h cnt sc.nextInt() sc.nextInt sc w[cnt] = sc.nextInt() w[cnt] w cnt sc.nextInt() sc.nextInt sc if(w[cnt] == 0 && h[cnt] == 0)
				break; w[cnt] == 0 && h[cnt] == 0 w[cnt] == 0 w[cnt] w cnt 0 h[cnt] == 0 h[cnt] h cnt 0 break; cnt ++ cnt for(int i = 0; i < cnt; i++){
			for(int j = 0; j < h[i]; j++){
				for(int k = 0; k < w[i]; k++){
					if(j == 0 || j == h[i] - 1 || k == 0 || k == w[i] - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println("");
			}
			System.out.println("");
		} int i = 0; int i = 0; i 0 i < cnt i cnt i++ i++ i {
			for(int j = 0; j < h[i]; j++){
				for(int k = 0; k < w[i]; k++){
					if(j == 0 || j == h[i] - 1 || k == 0 || k == w[i] - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println("");
			}
			System.out.println("");
		} {
			for(int j = 0; j < h[i]; j++){
				for(int k = 0; k < w[i]; k++){
					if(j == 0 || j == h[i] - 1 || k == 0 || k == w[i] - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println("");
			}
			System.out.println("");
		} for(int j = 0; j < h[i]; j++){
				for(int k = 0; k < w[i]; k++){
					if(j == 0 || j == h[i] - 1 || k == 0 || k == w[i] - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println("");
			} int j = 0; int j = 0; j 0 j < h[i] j h[i] h i j++ j++ j {
				for(int k = 0; k < w[i]; k++){
					if(j == 0 || j == h[i] - 1 || k == 0 || k == w[i] - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println("");
			} {
				for(int k = 0; k < w[i]; k++){
					if(j == 0 || j == h[i] - 1 || k == 0 || k == w[i] - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println("");
			} for(int k = 0; k < w[i]; k++){
					if(j == 0 || j == h[i] - 1 || k == 0 || k == w[i] - 1)
						System.out.print("#");
					else
						System.out.print(".");
				} int k = 0; int k = 0; k 0 k < w[i] k w[i] w i k++ k++ k {
					if(j == 0 || j == h[i] - 1 || k == 0 || k == w[i] - 1)
						System.out.print("#");
					else
						System.out.print(".");
				} {
					if(j == 0 || j == h[i] - 1 || k == 0 || k == w[i] - 1)
						System.out.print("#");
					else
						System.out.print(".");
				} if(j == 0 || j == h[i] - 1 || k == 0 || k == w[i] - 1)
						System.out.print("#");
					else
						System.out.print("."); j == 0 || j == h[i] - 1 || k == 0 || k == w[i] - 1 k == 0 j == 0 || j == h[i] - 1 || k == 0 || k == w[i] - 1 j == 0 j 0 j == h[i] - 1 j h[i] - 1 h[i] h i 1 k == 0 k 0 k == w[i] - 1 k w[i] - 1 w[i] w i 1 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
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int[] h = new int[300], w = new int[300];
		int cnt = 0;
		
		while(true){
			h[cnt] = sc.nextInt();
			w[cnt] = sc.nextInt();
			
			if(w[cnt] == 0 && h[cnt] == 0)
				break;
			
			cnt ++;
		}
		
		for(int i = 0; i < cnt; i++){
			for(int j = 0; j < h[i]; j++){
				for(int k = 0; k < w[i]; k++){
					if(j == 0 || j == h[i] - 1 || k == 0 || k == w[i] - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}