import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		
		while(true){
			if(h==0 && w==0) break;
			
	        StringBuilder shp1=new StringBuilder();
	        for(int p=0;p<w;p++){
	        	shp1.append("#");
	        }
	         
	        StringBuilder shp2=new StringBuilder();
	        shp2.append("#");
		    for(int p=0;p<w-2;p++){
	        	shp2.append(".");
	        }
	        shp2.append("#");
	                
	        System.out.println(shp1);
	        for (int i=0;i<h-2;i++){
	        	System.out.println(shp2);
	        }
	        System.out.println(shp1+"\n");
	        
			h=sc.nextInt();
			w=sc.nextInt();

		}
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		
		while(true){
			if(h==0 && w==0) break;
			
	        StringBuilder shp1=new StringBuilder();
	        for(int p=0;p<w;p++){
	        	shp1.append("#");
	        }
	         
	        StringBuilder shp2=new StringBuilder();
	        shp2.append("#");
		    for(int p=0;p<w-2;p++){
	        	shp2.append(".");
	        }
	        shp2.append("#");
	                
	        System.out.println(shp1);
	        for (int i=0;i<h-2;i++){
	        	System.out.println(shp2);
	        }
	        System.out.println(shp1+"\n");
	        
			h=sc.nextInt();
			w=sc.nextInt();

		}
	}

} Main public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		
		while(true){
			if(h==0 && w==0) break;
			
	        StringBuilder shp1=new StringBuilder();
	        for(int p=0;p<w;p++){
	        	shp1.append("#");
	        }
	         
	        StringBuilder shp2=new StringBuilder();
	        shp2.append("#");
		    for(int p=0;p<w-2;p++){
	        	shp2.append(".");
	        }
	        shp2.append("#");
	                
	        System.out.println(shp1);
	        for (int i=0;i<h-2;i++){
	        	System.out.println(shp2);
	        }
	        System.out.println(shp1+"\n");
	        
			h=sc.nextInt();
			w=sc.nextInt();

		}
	} main {
		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		
		while(true){
			if(h==0 && w==0) break;
			
	        StringBuilder shp1=new StringBuilder();
	        for(int p=0;p<w;p++){
	        	shp1.append("#");
	        }
	         
	        StringBuilder shp2=new StringBuilder();
	        shp2.append("#");
		    for(int p=0;p<w-2;p++){
	        	shp2.append(".");
	        }
	        shp2.append("#");
	                
	        System.out.println(shp1);
	        for (int i=0;i<h-2;i++){
	        	System.out.println(shp2);
	        }
	        System.out.println(shp1+"\n");
	        
			h=sc.nextInt();
			w=sc.nextInt();

		}
	} 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 while(true){
			if(h==0 && w==0) break;
			
	        StringBuilder shp1=new StringBuilder();
	        for(int p=0;p<w;p++){
	        	shp1.append("#");
	        }
	         
	        StringBuilder shp2=new StringBuilder();
	        shp2.append("#");
		    for(int p=0;p<w-2;p++){
	        	shp2.append(".");
	        }
	        shp2.append("#");
	                
	        System.out.println(shp1);
	        for (int i=0;i<h-2;i++){
	        	System.out.println(shp2);
	        }
	        System.out.println(shp1+"\n");
	        
			h=sc.nextInt();
			w=sc.nextInt();

		} true {
			if(h==0 && w==0) break;
			
	        StringBuilder shp1=new StringBuilder();
	        for(int p=0;p<w;p++){
	        	shp1.append("#");
	        }
	         
	        StringBuilder shp2=new StringBuilder();
	        shp2.append("#");
		    for(int p=0;p<w-2;p++){
	        	shp2.append(".");
	        }
	        shp2.append("#");
	                
	        System.out.println(shp1);
	        for (int i=0;i<h-2;i++){
	        	System.out.println(shp2);
	        }
	        System.out.println(shp1+"\n");
	        
			h=sc.nextInt();
			w=sc.nextInt();

		} if(h==0 && w==0) break; h==0 && w==0 h==0 h 0 w==0 w 0 break; StringBuilder shp1=new StringBuilder(); shp1 new StringBuilder() for(int p=0;p<w;p++){
	        	shp1.append("#");
	        } int p=0; int p=0; p 0 p<w p w p++ p++ p {
	        	shp1.append("#");
	        } {
	        	shp1.append("#");
	        } shp1.append("#") shp1.append shp1 "#" StringBuilder shp2=new StringBuilder(); shp2 new StringBuilder() shp2.append("#") shp2.append shp2 "#" for(int p=0;p<w-2;p++){
	        	shp2.append(".");
	        } int p=0; int p=0; p 0 p<w-2 p w-2 w 2 p++ p++ p {
	        	shp2.append(".");
	        } {
	        	shp2.append(".");
	        } shp2.append(".") shp2.append shp2 "." shp2.append("#") shp2.append shp2 "#" System.out.println(shp1) System.out.println System.out System System.out shp1 for (int i=0;i<h-2;i++){
	        	System.out.println(shp2);
	        } int i=0; int i=0; i 0 i<h-2 i h-2 h 2 i++ i++ i {
	        	System.out.println(shp2);
	        } {
	        	System.out.println(shp2);
	        } System.out.println(shp2) System.out.println System.out System System.out shp2 System.out.println(shp1+"\n") System.out.println System.out System System.out shp1+"\n" shp1 "\n" h=sc.nextInt() h sc.nextInt() sc.nextInt sc w=sc.nextInt() w sc.nextInt() sc.nextInt sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		
		while(true){
			if(h==0 && w==0) break;
			
	        StringBuilder shp1=new StringBuilder();
	        for(int p=0;p<w;p++){
	        	shp1.append("#");
	        }
	         
	        StringBuilder shp2=new StringBuilder();
	        shp2.append("#");
		    for(int p=0;p<w-2;p++){
	        	shp2.append(".");
	        }
	        shp2.append("#");
	                
	        System.out.println(shp1);
	        for (int i=0;i<h-2;i++){
	        	System.out.println(shp2);
	        }
	        System.out.println(shp1+"\n");
	        
			h=sc.nextInt();
			w=sc.nextInt();

		}
	}

} public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		
		while(true){
			if(h==0 && w==0) break;
			
	        StringBuilder shp1=new StringBuilder();
	        for(int p=0;p<w;p++){
	        	shp1.append("#");
	        }
	         
	        StringBuilder shp2=new StringBuilder();
	        shp2.append("#");
		    for(int p=0;p<w-2;p++){
	        	shp2.append(".");
	        }
	        shp2.append("#");
	                
	        System.out.println(shp1);
	        for (int i=0;i<h-2;i++){
	        	System.out.println(shp2);
	        }
	        System.out.println(shp1+"\n");
	        
			h=sc.nextInt();
			w=sc.nextInt();

		}
	}

} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		
		while(true){
			if(h==0 && w==0) break;
			
	        StringBuilder shp1=new StringBuilder();
	        for(int p=0;p<w;p++){
	        	shp1.append("#");
	        }
	         
	        StringBuilder shp2=new StringBuilder();
	        shp2.append("#");
		    for(int p=0;p<w-2;p++){
	        	shp2.append(".");
	        }
	        shp2.append("#");
	                
	        System.out.println(shp1);
	        for (int i=0;i<h-2;i++){
	        	System.out.println(shp2);
	        }
	        System.out.println(shp1+"\n");
	        
			h=sc.nextInt();
			w=sc.nextInt();

		}
	}

}