import java.io.*;

class Main{
 public static void main(String[] args)throws IOException{
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
   String[] strAry; 
   int H,W,i,j;
      
   while(true){
     strAry = br.readLine().split(" ");
     H = Integer.parseInt(strAry[0]);  
     W = Integer.parseInt(strAry[1]);
     if(H==0&&W==0) break;
     for(j=0;j<H;j++){
       for(i=0;i<W;i++){
        if(j==0||j==H-1||i==0||i==W-1){
         System.out.print("#");
        }else{
         System.out.print(".");
        }
       }
       System.out.print("\n");  
     }     
     System.out.print("\n");  
     
    }  
      


  }
} import java.io.*; io.* java class Main{
 public static void main(String[] args)throws IOException{
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
   String[] strAry; 
   int H,W,i,j;
      
   while(true){
     strAry = br.readLine().split(" ");
     H = Integer.parseInt(strAry[0]);  
     W = Integer.parseInt(strAry[1]);
     if(H==0&&W==0) break;
     for(j=0;j<H;j++){
       for(i=0;i<W;i++){
        if(j==0||j==H-1||i==0||i==W-1){
         System.out.print("#");
        }else{
         System.out.print(".");
        }
       }
       System.out.print("\n");  
     }     
     System.out.print("\n");  
     
    }  
      


  }
} Main public static void main(String[] args)throws IOException{
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
   String[] strAry; 
   int H,W,i,j;
      
   while(true){
     strAry = br.readLine().split(" ");
     H = Integer.parseInt(strAry[0]);  
     W = Integer.parseInt(strAry[1]);
     if(H==0&&W==0) break;
     for(j=0;j<H;j++){
       for(i=0;i<W;i++){
        if(j==0||j==H-1||i==0||i==W-1){
         System.out.print("#");
        }else{
         System.out.print(".");
        }
       }
       System.out.print("\n");  
     }     
     System.out.print("\n");  
     
    }  
      


  } main {
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
   String[] strAry; 
   int H,W,i,j;
      
   while(true){
     strAry = br.readLine().split(" ");
     H = Integer.parseInt(strAry[0]);  
     W = Integer.parseInt(strAry[1]);
     if(H==0&&W==0) break;
     for(j=0;j<H;j++){
       for(i=0;i<W;i++){
        if(j==0||j==H-1||i==0||i==W-1){
         System.out.print("#");
        }else{
         System.out.print(".");
        }
       }
       System.out.print("\n");  
     }     
     System.out.print("\n");  
     
    }  
      


  } BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] strAry; strAry int H H W W i i j; j while(true){
     strAry = br.readLine().split(" ");
     H = Integer.parseInt(strAry[0]);  
     W = Integer.parseInt(strAry[1]);
     if(H==0&&W==0) break;
     for(j=0;j<H;j++){
       for(i=0;i<W;i++){
        if(j==0||j==H-1||i==0||i==W-1){
         System.out.print("#");
        }else{
         System.out.print(".");
        }
       }
       System.out.print("\n");  
     }     
     System.out.print("\n");  
     
    } true {
     strAry = br.readLine().split(" ");
     H = Integer.parseInt(strAry[0]);  
     W = Integer.parseInt(strAry[1]);
     if(H==0&&W==0) break;
     for(j=0;j<H;j++){
       for(i=0;i<W;i++){
        if(j==0||j==H-1||i==0||i==W-1){
         System.out.print("#");
        }else{
         System.out.print(".");
        }
       }
       System.out.print("\n");  
     }     
     System.out.print("\n");  
     
    } strAry = br.readLine().split(" ") strAry br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " H = Integer.parseInt(strAry[0]) H Integer.parseInt(strAry[0]) Integer.parseInt Integer strAry[0] strAry 0 W = Integer.parseInt(strAry[1]) W Integer.parseInt(strAry[1]) Integer.parseInt Integer strAry[1] strAry 1 if(H==0&&W==0) break; H==0&&W==0 H==0 H 0 W==0 W 0 break; for(j=0;j<H;j++){
       for(i=0;i<W;i++){
        if(j==0||j==H-1||i==0||i==W-1){
         System.out.print("#");
        }else{
         System.out.print(".");
        }
       }
       System.out.print("\n");  
     } j=0; j=0 j 0 j<H j H j++ j++ j {
       for(i=0;i<W;i++){
        if(j==0||j==H-1||i==0||i==W-1){
         System.out.print("#");
        }else{
         System.out.print(".");
        }
       }
       System.out.print("\n");  
     } {
       for(i=0;i<W;i++){
        if(j==0||j==H-1||i==0||i==W-1){
         System.out.print("#");
        }else{
         System.out.print(".");
        }
       }
       System.out.print("\n");  
     } for(i=0;i<W;i++){
        if(j==0||j==H-1||i==0||i==W-1){
         System.out.print("#");
        }else{
         System.out.print(".");
        }
       } i=0; i=0 i 0 i<W i W i++ i++ i {
        if(j==0||j==H-1||i==0||i==W-1){
         System.out.print("#");
        }else{
         System.out.print(".");
        }
       } {
        if(j==0||j==H-1||i==0||i==W-1){
         System.out.print("#");
        }else{
         System.out.print(".");
        }
       } if(j==0||j==H-1||i==0||i==W-1){
         System.out.print("#");
        }else{
         System.out.print(".");
        } j==0||j==H-1||i==0||i==W-1 i==0 j==0||j==H-1||i==0||i==W-1 j==0 j 0 j==H-1 j H-1 H 1 i==0 i 0 i==W-1 i W-1 W 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.print("\n") System.out.print System.out System System.out "\n" System.out.print("\n") System.out.print System.out System System.out "\n" String[] args args
import java.io.*;

class Main{
 public static void main(String[] args)throws IOException{
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
   String[] strAry; 
   int H,W,i,j;
      
   while(true){
     strAry = br.readLine().split(" ");
     H = Integer.parseInt(strAry[0]);  
     W = Integer.parseInt(strAry[1]);
     if(H==0&&W==0) break;
     for(j=0;j<H;j++){
       for(i=0;i<W;i++){
        if(j==0||j==H-1||i==0||i==W-1){
         System.out.print("#");
        }else{
         System.out.print(".");
        }
       }
       System.out.print("\n");  
     }     
     System.out.print("\n");  
     
    }  
      


  }
}