import java.util.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str;
      String[] arr;
      int height;
      int width;
      
      while(true){
         str = sc.nextLine();
         arr = str.split(" ");
         height = Integer.parseInt(arr[0]);
         width = Integer.parseInt(arr[1]);
      
         if(height == 0){
            break;
         }
      
         edge(width);
         System.out.println();
         middle(height - 2, width);
         edge(width);
         System.out.println("\n");
      
      }
      
         
   }//main method 
   
   
   public static void edge(int width){
      for(int i = 0; i < width; i++){
         System.out.print("#");
      }
   }
   
   public static void middle(int n,int  width){
      for(int i = 0; i < n; i ++){
         System.out.print("#");
         for(int j = 0; j < width - 2; j++){
            System.out.print(".");
         }
         System.out.print("#\n");
      }
   }
}//class import java.util.*; util.* java public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str;
      String[] arr;
      int height;
      int width;
      
      while(true){
         str = sc.nextLine();
         arr = str.split(" ");
         height = Integer.parseInt(arr[0]);
         width = Integer.parseInt(arr[1]);
      
         if(height == 0){
            break;
         }
      
         edge(width);
         System.out.println();
         middle(height - 2, width);
         edge(width);
         System.out.println("\n");
      
      }
      
         
   }//main method 
   
   
   public static void edge(int width){
      for(int i = 0; i < width; i++){
         System.out.print("#");
      }
   }
   
   public static void middle(int n,int  width){
      for(int i = 0; i < n; i ++){
         System.out.print("#");
         for(int j = 0; j < width - 2; j++){
            System.out.print(".");
         }
         System.out.print("#\n");
      }
   }
}//class Main public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str;
      String[] arr;
      int height;
      int width;
      
      while(true){
         str = sc.nextLine();
         arr = str.split(" ");
         height = Integer.parseInt(arr[0]);
         width = Integer.parseInt(arr[1]);
      
         if(height == 0){
            break;
         }
      
         edge(width);
         System.out.println();
         middle(height - 2, width);
         edge(width);
         System.out.println("\n");
      
      }
      
         
   }//main method  main {
      Scanner sc = new Scanner(System.in);
      String str;
      String[] arr;
      int height;
      int width;
      
      while(true){
         str = sc.nextLine();
         arr = str.split(" ");
         height = Integer.parseInt(arr[0]);
         width = Integer.parseInt(arr[1]);
      
         if(height == 0){
            break;
         }
      
         edge(width);
         System.out.println();
         middle(height - 2, width);
         edge(width);
         System.out.println("\n");
      
      }
      
         
   } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str; str String[] arr; arr int height; height int width; width while(true){
         str = sc.nextLine();
         arr = str.split(" ");
         height = Integer.parseInt(arr[0]);
         width = Integer.parseInt(arr[1]);
      
         if(height == 0){
            break;
         }
      
         edge(width);
         System.out.println();
         middle(height - 2, width);
         edge(width);
         System.out.println("\n");
      
      } true {
         str = sc.nextLine();
         arr = str.split(" ");
         height = Integer.parseInt(arr[0]);
         width = Integer.parseInt(arr[1]);
      
         if(height == 0){
            break;
         }
      
         edge(width);
         System.out.println();
         middle(height - 2, width);
         edge(width);
         System.out.println("\n");
      
      } str = sc.nextLine() str sc.nextLine() sc.nextLine sc arr = str.split(" ") arr str.split(" ") str.split str " " height = Integer.parseInt(arr[0]) height Integer.parseInt(arr[0]) Integer.parseInt Integer arr[0] arr 0 width = Integer.parseInt(arr[1]) width Integer.parseInt(arr[1]) Integer.parseInt Integer arr[1] arr 1 if(height == 0){
            break;
         } height == 0 height 0 {
            break;
         } break; edge(width) edge width System.out.println() System.out.println System.out System System.out middle(height - 2, width) middle height - 2 height 2 width edge(width) edge width System.out.println("\n") System.out.println System.out System System.out "\n" String[] args args public static void edge(int width){
      for(int i = 0; i < width; i++){
         System.out.print("#");
      }
   } edge {
      for(int i = 0; i < width; i++){
         System.out.print("#");
      }
   } for(int i = 0; i < width; i++){
         System.out.print("#");
      } int i = 0; int i = 0; i 0 i < width i width i++ i++ i {
         System.out.print("#");
      } {
         System.out.print("#");
      } System.out.print("#") System.out.print System.out System System.out "#" int width width public static void middle(int n,int  width){
      for(int i = 0; i < n; i ++){
         System.out.print("#");
         for(int j = 0; j < width - 2; j++){
            System.out.print(".");
         }
         System.out.print("#\n");
      }
   } middle {
      for(int i = 0; i < n; i ++){
         System.out.print("#");
         for(int j = 0; j < width - 2; j++){
            System.out.print(".");
         }
         System.out.print("#\n");
      }
   } for(int i = 0; i < n; i ++){
         System.out.print("#");
         for(int j = 0; j < width - 2; j++){
            System.out.print(".");
         }
         System.out.print("#\n");
      } int i = 0; int i = 0; i 0 i < n i n i ++ i ++ i {
         System.out.print("#");
         for(int j = 0; j < width - 2; j++){
            System.out.print(".");
         }
         System.out.print("#\n");
      } {
         System.out.print("#");
         for(int j = 0; j < width - 2; j++){
            System.out.print(".");
         }
         System.out.print("#\n");
      } System.out.print("#") System.out.print System.out System System.out "#" for(int j = 0; j < width - 2; j++){
            System.out.print(".");
         } int j = 0; int j = 0; j 0 j < width - 2 j width - 2 width 2 j++ j++ j {
            System.out.print(".");
         } {
            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" int n n int  width width public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str;
      String[] arr;
      int height;
      int width;
      
      while(true){
         str = sc.nextLine();
         arr = str.split(" ");
         height = Integer.parseInt(arr[0]);
         width = Integer.parseInt(arr[1]);
      
         if(height == 0){
            break;
         }
      
         edge(width);
         System.out.println();
         middle(height - 2, width);
         edge(width);
         System.out.println("\n");
      
      }
      
         
   }//main method 
   
   
   public static void edge(int width){
      for(int i = 0; i < width; i++){
         System.out.print("#");
      }
   }
   
   public static void middle(int n,int  width){
      for(int i = 0; i < n; i ++){
         System.out.print("#");
         for(int j = 0; j < width - 2; j++){
            System.out.print(".");
         }
         System.out.print("#\n");
      }
   }
}//class public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str;
      String[] arr;
      int height;
      int width;
      
      while(true){
         str = sc.nextLine();
         arr = str.split(" ");
         height = Integer.parseInt(arr[0]);
         width = Integer.parseInt(arr[1]);
      
         if(height == 0){
            break;
         }
      
         edge(width);
         System.out.println();
         middle(height - 2, width);
         edge(width);
         System.out.println("\n");
      
      }
      
         
   }//main method 
   
   
   public static void edge(int width){
      for(int i = 0; i < width; i++){
         System.out.print("#");
      }
   }
   
   public static void middle(int n,int  width){
      for(int i = 0; i < n; i ++){
         System.out.print("#");
         for(int j = 0; j < width - 2; j++){
            System.out.print(".");
         }
         System.out.print("#\n");
      }
   }
}//class Main
import java.util.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str;
      String[] arr;
      int height;
      int width;
      
      while(true){
         str = sc.nextLine();
         arr = str.split(" ");
         height = Integer.parseInt(arr[0]);
         width = Integer.parseInt(arr[1]);
      
         if(height == 0){
            break;
         }
      
         edge(width);
         System.out.println();
         middle(height - 2, width);
         edge(width);
         System.out.println("\n");
      
      }
      
         
   }//main method 
   
   
   public static void edge(int width){
      for(int i = 0; i < width; i++){
         System.out.print("#");
      }
   }
   
   public static void middle(int n,int  width){
      for(int i = 0; i < n; i ++){
         System.out.print("#");
         for(int j = 0; j < width - 2; j++){
            System.out.print(".");
         }
         System.out.print("#\n");
      }
   }
}//class