import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
class Main{
	public static void main(String[] args){
	int h =0;
	int w =0;
	int t =0;
	Scanner scan = new Scanner(System.in);
	ArrayList<Integer> listw = new ArrayList<Integer>();
	ArrayList<Integer> listh = new ArrayList<Integer>();
		while(scan.hasNextLine()){
			h = scan.nextInt();			
			w = scan.nextInt();
			
			if(h==0 && w==0){
				break;
			}
			else{
				listh.add(h);
				listw.add(w);
			}
		}
		
		
		
		for(int i=0;i<listh.size();i++){
			for(int ii=0;ii<listh.get(i);ii++){
				for(int iii=0;iii<listw.get(i);iii++){
					if(ii == 0 || ii ==listh.get(i)-1 || iii == 0 || iii == listw.get(i)-1){
					System.out.print("#");
					}
					else{
					System.out.print(".");
					}
					
				}
			System.out.println("");
			}
		System.out.println("");
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.*; util.* java class Main{
	public static void main(String[] args){
	int h =0;
	int w =0;
	int t =0;
	Scanner scan = new Scanner(System.in);
	ArrayList<Integer> listw = new ArrayList<Integer>();
	ArrayList<Integer> listh = new ArrayList<Integer>();
		while(scan.hasNextLine()){
			h = scan.nextInt();			
			w = scan.nextInt();
			
			if(h==0 && w==0){
				break;
			}
			else{
				listh.add(h);
				listw.add(w);
			}
		}
		
		
		
		for(int i=0;i<listh.size();i++){
			for(int ii=0;ii<listh.get(i);ii++){
				for(int iii=0;iii<listw.get(i);iii++){
					if(ii == 0 || ii ==listh.get(i)-1 || iii == 0 || iii == listw.get(i)-1){
					System.out.print("#");
					}
					else{
					System.out.print(".");
					}
					
				}
			System.out.println("");
			}
		System.out.println("");
		}
	}
} Main public static void main(String[] args){
	int h =0;
	int w =0;
	int t =0;
	Scanner scan = new Scanner(System.in);
	ArrayList<Integer> listw = new ArrayList<Integer>();
	ArrayList<Integer> listh = new ArrayList<Integer>();
		while(scan.hasNextLine()){
			h = scan.nextInt();			
			w = scan.nextInt();
			
			if(h==0 && w==0){
				break;
			}
			else{
				listh.add(h);
				listw.add(w);
			}
		}
		
		
		
		for(int i=0;i<listh.size();i++){
			for(int ii=0;ii<listh.get(i);ii++){
				for(int iii=0;iii<listw.get(i);iii++){
					if(ii == 0 || ii ==listh.get(i)-1 || iii == 0 || iii == listw.get(i)-1){
					System.out.print("#");
					}
					else{
					System.out.print(".");
					}
					
				}
			System.out.println("");
			}
		System.out.println("");
		}
	} main {
	int h =0;
	int w =0;
	int t =0;
	Scanner scan = new Scanner(System.in);
	ArrayList<Integer> listw = new ArrayList<Integer>();
	ArrayList<Integer> listh = new ArrayList<Integer>();
		while(scan.hasNextLine()){
			h = scan.nextInt();			
			w = scan.nextInt();
			
			if(h==0 && w==0){
				break;
			}
			else{
				listh.add(h);
				listw.add(w);
			}
		}
		
		
		
		for(int i=0;i<listh.size();i++){
			for(int ii=0;ii<listh.get(i);ii++){
				for(int iii=0;iii<listw.get(i);iii++){
					if(ii == 0 || ii ==listh.get(i)-1 || iii == 0 || iii == listw.get(i)-1){
					System.out.print("#");
					}
					else{
					System.out.print(".");
					}
					
				}
			System.out.println("");
			}
		System.out.println("");
		}
	} int h =0; h 0 int w =0; w 0 int t =0; t 0 Scanner scan = new Scanner(System.in); scan new Scanner(System.in) ArrayList<Integer> listw = new ArrayList<Integer>(); listw new ArrayList<Integer>() ArrayList<Integer> listh = new ArrayList<Integer>(); listh new ArrayList<Integer>() while(scan.hasNextLine()){
			h = scan.nextInt();			
			w = scan.nextInt();
			
			if(h==0 && w==0){
				break;
			}
			else{
				listh.add(h);
				listw.add(w);
			}
		} scan.hasNextLine() scan.hasNextLine scan {
			h = scan.nextInt();			
			w = scan.nextInt();
			
			if(h==0 && w==0){
				break;
			}
			else{
				listh.add(h);
				listw.add(w);
			}
		} h = scan.nextInt() h scan.nextInt() scan.nextInt scan w = scan.nextInt() w scan.nextInt() scan.nextInt scan if(h==0 && w==0){
				break;
			}
			else{
				listh.add(h);
				listw.add(w);
			} h==0 && w==0 h==0 h 0 w==0 w 0 {
				break;
			} break; {
				listh.add(h);
				listw.add(w);
			} listh.add(h) listh.add listh h listw.add(w) listw.add listw w for(int i=0;i<listh.size();i++){
			for(int ii=0;ii<listh.get(i);ii++){
				for(int iii=0;iii<listw.get(i);iii++){
					if(ii == 0 || ii ==listh.get(i)-1 || iii == 0 || iii == listw.get(i)-1){
					System.out.print("#");
					}
					else{
					System.out.print(".");
					}
					
				}
			System.out.println("");
			}
		System.out.println("");
		} int i=0; int i=0; i 0 i<listh.size() i listh.size() listh.size listh i++ i++ i {
			for(int ii=0;ii<listh.get(i);ii++){
				for(int iii=0;iii<listw.get(i);iii++){
					if(ii == 0 || ii ==listh.get(i)-1 || iii == 0 || iii == listw.get(i)-1){
					System.out.print("#");
					}
					else{
					System.out.print(".");
					}
					
				}
			System.out.println("");
			}
		System.out.println("");
		} {
			for(int ii=0;ii<listh.get(i);ii++){
				for(int iii=0;iii<listw.get(i);iii++){
					if(ii == 0 || ii ==listh.get(i)-1 || iii == 0 || iii == listw.get(i)-1){
					System.out.print("#");
					}
					else{
					System.out.print(".");
					}
					
				}
			System.out.println("");
			}
		System.out.println("");
		} for(int ii=0;ii<listh.get(i);ii++){
				for(int iii=0;iii<listw.get(i);iii++){
					if(ii == 0 || ii ==listh.get(i)-1 || iii == 0 || iii == listw.get(i)-1){
					System.out.print("#");
					}
					else{
					System.out.print(".");
					}
					
				}
			System.out.println("");
			} int ii=0; int ii=0; ii 0 ii<listh.get(i) ii listh.get(i) listh.get listh i ii++ ii++ ii {
				for(int iii=0;iii<listw.get(i);iii++){
					if(ii == 0 || ii ==listh.get(i)-1 || iii == 0 || iii == listw.get(i)-1){
					System.out.print("#");
					}
					else{
					System.out.print(".");
					}
					
				}
			System.out.println("");
			} {
				for(int iii=0;iii<listw.get(i);iii++){
					if(ii == 0 || ii ==listh.get(i)-1 || iii == 0 || iii == listw.get(i)-1){
					System.out.print("#");
					}
					else{
					System.out.print(".");
					}
					
				}
			System.out.println("");
			} for(int iii=0;iii<listw.get(i);iii++){
					if(ii == 0 || ii ==listh.get(i)-1 || iii == 0 || iii == listw.get(i)-1){
					System.out.print("#");
					}
					else{
					System.out.print(".");
					}
					
				} int iii=0; int iii=0; iii 0 iii<listw.get(i) iii listw.get(i) listw.get listw i iii++ iii++ iii {
					if(ii == 0 || ii ==listh.get(i)-1 || iii == 0 || iii == listw.get(i)-1){
					System.out.print("#");
					}
					else{
					System.out.print(".");
					}
					
				} {
					if(ii == 0 || ii ==listh.get(i)-1 || iii == 0 || iii == listw.get(i)-1){
					System.out.print("#");
					}
					else{
					System.out.print(".");
					}
					
				} if(ii == 0 || ii ==listh.get(i)-1 || iii == 0 || iii == listw.get(i)-1){
					System.out.print("#");
					}
					else{
					System.out.print(".");
					} ii == 0 || ii ==listh.get(i)-1 || iii == 0 || iii == listw.get(i)-1 iii == 0 ii == 0 || ii ==listh.get(i)-1 || iii == 0 || iii == listw.get(i)-1 ii == 0 ii 0 ii ==listh.get(i)-1 ii listh.get(i)-1 listh.get(i) listh.get listh i 1 iii == 0 iii 0 iii == listw.get(i)-1 iii listw.get(i)-1 listw.get(i) listw.get listw i 1 {
					System.out.print("#");
					} System.out.print("#") System.out.print System.out System System.out "#" {
					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 "" System.out.println("") System.out.println System.out System System.out "" String[] args args
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
class Main{
	public static void main(String[] args){
	int h =0;
	int w =0;
	int t =0;
	Scanner scan = new Scanner(System.in);
	ArrayList<Integer> listw = new ArrayList<Integer>();
	ArrayList<Integer> listh = new ArrayList<Integer>();
		while(scan.hasNextLine()){
			h = scan.nextInt();			
			w = scan.nextInt();
			
			if(h==0 && w==0){
				break;
			}
			else{
				listh.add(h);
				listw.add(w);
			}
		}
		
		
		
		for(int i=0;i<listh.size();i++){
			for(int ii=0;ii<listh.get(i);ii++){
				for(int iii=0;iii<listw.get(i);iii++){
					if(ii == 0 || ii ==listh.get(i)-1 || iii == 0 || iii == listw.get(i)-1){
					System.out.print("#");
					}
					else{
					System.out.print(".");
					}
					
				}
			System.out.println("");
			}
		System.out.println("");
		}
	}
}