import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder Newbuilt = new StringBuilder(); //????????´?????????????????????
      //H??¨W?????\?????????????????????????????§???  
        while (true) {
            String[] array = sc.nextLine().split(" ");
            int H = Integer.parseInt(array[0]);
            int W = Integer.parseInt(array[1]);
            if (H == 0 && W == 0) break ;
      //????????¢?????¢???????¨???????????????¶ HxW
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if(i == 0 || i == H-1 || j == 0 || j == W-1)
                        Newbuilt.append("#");
                    else
                        Newbuilt.append(".");

                }
                Newbuilt.append("\n");
            }
            Newbuilt.append("\n");
             
        }
       //StringBuilder????????????????????????????????????????????????????????????
        System.out.print(Newbuilt);
        
        sc.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder Newbuilt = new StringBuilder(); //????????´?????????????????????
      //H??¨W?????\?????????????????????????????§???  
        while (true) {
            String[] array = sc.nextLine().split(" ");
            int H = Integer.parseInt(array[0]);
            int W = Integer.parseInt(array[1]);
            if (H == 0 && W == 0) break ;
      //????????¢?????¢???????¨???????????????¶ HxW
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if(i == 0 || i == H-1 || j == 0 || j == W-1)
                        Newbuilt.append("#");
                    else
                        Newbuilt.append(".");

                }
                Newbuilt.append("\n");
            }
            Newbuilt.append("\n");
             
        }
       //StringBuilder????????????????????????????????????????????????????????????
        System.out.print(Newbuilt);
        
        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder Newbuilt = new StringBuilder(); //????????´?????????????????????
      //H??¨W?????\?????????????????????????????§???  
        while (true) {
            String[] array = sc.nextLine().split(" ");
            int H = Integer.parseInt(array[0]);
            int W = Integer.parseInt(array[1]);
            if (H == 0 && W == 0) break ;
      //????????¢?????¢???????¨???????????????¶ HxW
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if(i == 0 || i == H-1 || j == 0 || j == W-1)
                        Newbuilt.append("#");
                    else
                        Newbuilt.append(".");

                }
                Newbuilt.append("\n");
            }
            Newbuilt.append("\n");
             
        }
       //StringBuilder????????????????????????????????????????????????????????????
        System.out.print(Newbuilt);
        
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        StringBuilder Newbuilt = new StringBuilder(); //????????´?????????????????????
      //H??¨W?????\?????????????????????????????§???  
        while (true) {
            String[] array = sc.nextLine().split(" ");
            int H = Integer.parseInt(array[0]);
            int W = Integer.parseInt(array[1]);
            if (H == 0 && W == 0) break ;
      //????????¢?????¢???????¨???????????????¶ HxW
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if(i == 0 || i == H-1 || j == 0 || j == W-1)
                        Newbuilt.append("#");
                    else
                        Newbuilt.append(".");

                }
                Newbuilt.append("\n");
            }
            Newbuilt.append("\n");
             
        }
       //StringBuilder????????????????????????????????????????????????????????????
        System.out.print(Newbuilt);
        
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) StringBuilder Newbuilt = new StringBuilder(); Newbuilt new StringBuilder() while (true) {
            String[] array = sc.nextLine().split(" ");
            int H = Integer.parseInt(array[0]);
            int W = Integer.parseInt(array[1]);
            if (H == 0 && W == 0) break ;
      //????????¢?????¢???????¨???????????????¶ HxW
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if(i == 0 || i == H-1 || j == 0 || j == W-1)
                        Newbuilt.append("#");
                    else
                        Newbuilt.append(".");

                }
                Newbuilt.append("\n");
            }
            Newbuilt.append("\n");
             
        } true {
            String[] array = sc.nextLine().split(" ");
            int H = Integer.parseInt(array[0]);
            int W = Integer.parseInt(array[1]);
            if (H == 0 && W == 0) break ;
      //????????¢?????¢???????¨???????????????¶ HxW
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if(i == 0 || i == H-1 || j == 0 || j == W-1)
                        Newbuilt.append("#");
                    else
                        Newbuilt.append(".");

                }
                Newbuilt.append("\n");
            }
            Newbuilt.append("\n");
             
        } String[] array = sc.nextLine().split(" "); array sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int H = Integer.parseInt(array[0]); H Integer.parseInt(array[0]) Integer.parseInt Integer array[0] array 0 int W = Integer.parseInt(array[1]); W Integer.parseInt(array[1]) Integer.parseInt Integer array[1] array 1 if (H == 0 && W == 0) break ; H == 0 && W == 0 H == 0 H 0 W == 0 W 0 break ; for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if(i == 0 || i == H-1 || j == 0 || j == W-1)
                        Newbuilt.append("#");
                    else
                        Newbuilt.append(".");

                }
                Newbuilt.append("\n");
            } int i = 0; int i = 0; i 0 i < H i H i++ i++ i {
                for (int j = 0; j < W; j++) {
                    if(i == 0 || i == H-1 || j == 0 || j == W-1)
                        Newbuilt.append("#");
                    else
                        Newbuilt.append(".");

                }
                Newbuilt.append("\n");
            } {
                for (int j = 0; j < W; j++) {
                    if(i == 0 || i == H-1 || j == 0 || j == W-1)
                        Newbuilt.append("#");
                    else
                        Newbuilt.append(".");

                }
                Newbuilt.append("\n");
            } for (int j = 0; j < W; j++) {
                    if(i == 0 || i == H-1 || j == 0 || j == W-1)
                        Newbuilt.append("#");
                    else
                        Newbuilt.append(".");

                } int j = 0; int j = 0; j 0 j < W j W j++ j++ j {
                    if(i == 0 || i == H-1 || j == 0 || j == W-1)
                        Newbuilt.append("#");
                    else
                        Newbuilt.append(".");

                } {
                    if(i == 0 || i == H-1 || j == 0 || j == W-1)
                        Newbuilt.append("#");
                    else
                        Newbuilt.append(".");

                } if(i == 0 || i == H-1 || j == 0 || j == W-1)
                        Newbuilt.append("#");
                    else
                        Newbuilt.append("."); i == 0 || i == H-1 || j == 0 || j == W-1 j == 0 i == 0 || i == H-1 || j == 0 || j == W-1 i == 0 i 0 i == H-1 i H-1 H 1 j == 0 j 0 j == W-1 j W-1 W 1 Newbuilt.append("#") Newbuilt.append Newbuilt "#" Newbuilt.append(".") Newbuilt.append Newbuilt "." Newbuilt.append("\n") Newbuilt.append Newbuilt "\n" Newbuilt.append("\n") Newbuilt.append Newbuilt "\n" System.out.print(Newbuilt) System.out.print System.out System System.out Newbuilt sc.close() sc.close sc String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder Newbuilt = new StringBuilder(); //????????´?????????????????????
      //H??¨W?????\?????????????????????????????§???  
        while (true) {
            String[] array = sc.nextLine().split(" ");
            int H = Integer.parseInt(array[0]);
            int W = Integer.parseInt(array[1]);
            if (H == 0 && W == 0) break ;
      //????????¢?????¢???????¨???????????????¶ HxW
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if(i == 0 || i == H-1 || j == 0 || j == W-1)
                        Newbuilt.append("#");
                    else
                        Newbuilt.append(".");

                }
                Newbuilt.append("\n");
            }
            Newbuilt.append("\n");
             
        }
       //StringBuilder????????????????????????????????????????????????????????????
        System.out.print(Newbuilt);
        
        sc.close();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder Newbuilt = new StringBuilder(); //????????´?????????????????????
      //H??¨W?????\?????????????????????????????§???  
        while (true) {
            String[] array = sc.nextLine().split(" ");
            int H = Integer.parseInt(array[0]);
            int W = Integer.parseInt(array[1]);
            if (H == 0 && W == 0) break ;
      //????????¢?????¢???????¨???????????????¶ HxW
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if(i == 0 || i == H-1 || j == 0 || j == W-1)
                        Newbuilt.append("#");
                    else
                        Newbuilt.append(".");

                }
                Newbuilt.append("\n");
            }
            Newbuilt.append("\n");
             
        }
       //StringBuilder????????????????????????????????????????????????????????????
        System.out.print(Newbuilt);
        
        sc.close();
    }
} Main
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder Newbuilt = new StringBuilder(); //????????´?????????????????????
      //H??¨W?????\?????????????????????????????§???  
        while (true) {
            String[] array = sc.nextLine().split(" ");
            int H = Integer.parseInt(array[0]);
            int W = Integer.parseInt(array[1]);
            if (H == 0 && W == 0) break ;
      //????????¢?????¢???????¨???????????????¶ HxW
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if(i == 0 || i == H-1 || j == 0 || j == W-1)
                        Newbuilt.append("#");
                    else
                        Newbuilt.append(".");

                }
                Newbuilt.append("\n");
            }
            Newbuilt.append("\n");
             
        }
       //StringBuilder????????????????????????????????????????????????????????????
        System.out.print(Newbuilt);
        
        sc.close();
    }
}