import java.util.*;


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


public class Main {
	static int w;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()){
          int h=sc.nextInt();
          w=sc.nextInt();
          if(h==0&&w==0)break;
          mm();
          for(int  i=0;i<h-2;i++){
        	 System.out.print("#");
        	 for(int j=0;j<w-2;j++){
        	    	System.out.print(".");  	
            	}
        	 System.out.println("#"); 
           }
          mm();
          System.out.println();
          
        }
			
    }
    static void mm(){
    	for(int j=0;j<w;j++){
    		System.out.print("#");
    		
    	}
    	System.out.println();
    }
}