import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String str = br.readLine();
        
        while(str != null){
            String[] line = str.split("\\s");
            int H = Integer.parseInt(line[0]);
            int W = Integer.parseInt(line[1]);
            //System.out.println(H);
            //System.out.println(W);

            if(H ==0 && W == 0){
                break;
            }else{
                String TB = createTB(W);
                String IW = createIW(W);
                
                System.out.println(TB);
                for(int i=0;i<H-2;i++){
                    System.out.println(IW);
                }
                System.out.println(TB);
                System.out.println("");
            }
            str =br.readLine();
        }
        br.close();
    }

    public static String createTB(int W){
        String temp ="";
        for(int i =0;i<W;i++){
            temp +="#";
        }
        return temp;
    }
    
    public static String createIW(int W){
        StringBuilder temp = new StringBuilder();
            temp.append("#");
            for(int i=0;i<W-2;i++){
                temp.append(".");
            }
                temp.append("#");
                return temp.toString();
        }
} import java.io.*; io.* java import java.util.*; util.* java public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String str = br.readLine();
        
        while(str != null){
            String[] line = str.split("\\s");
            int H = Integer.parseInt(line[0]);
            int W = Integer.parseInt(line[1]);
            //System.out.println(H);
            //System.out.println(W);

            if(H ==0 && W == 0){
                break;
            }else{
                String TB = createTB(W);
                String IW = createIW(W);
                
                System.out.println(TB);
                for(int i=0;i<H-2;i++){
                    System.out.println(IW);
                }
                System.out.println(TB);
                System.out.println("");
            }
            str =br.readLine();
        }
        br.close();
    }

    public static String createTB(int W){
        String temp ="";
        for(int i =0;i<W;i++){
            temp +="#";
        }
        return temp;
    }
    
    public static String createIW(int W){
        StringBuilder temp = new StringBuilder();
            temp.append("#");
            for(int i=0;i<W-2;i++){
                temp.append(".");
            }
                temp.append("#");
                return temp.toString();
        }
} Main public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String str = br.readLine();
        
        while(str != null){
            String[] line = str.split("\\s");
            int H = Integer.parseInt(line[0]);
            int W = Integer.parseInt(line[1]);
            //System.out.println(H);
            //System.out.println(W);

            if(H ==0 && W == 0){
                break;
            }else{
                String TB = createTB(W);
                String IW = createIW(W);
                
                System.out.println(TB);
                for(int i=0;i<H-2;i++){
                    System.out.println(IW);
                }
                System.out.println(TB);
                System.out.println("");
            }
            str =br.readLine();
        }
        br.close();
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String str = br.readLine();
        
        while(str != null){
            String[] line = str.split("\\s");
            int H = Integer.parseInt(line[0]);
            int W = Integer.parseInt(line[1]);
            //System.out.println(H);
            //System.out.println(W);

            if(H ==0 && W == 0){
                break;
            }else{
                String TB = createTB(W);
                String IW = createIW(W);
                
                System.out.println(TB);
                for(int i=0;i<H-2;i++){
                    System.out.println(IW);
                }
                System.out.println(TB);
                System.out.println("");
            }
            str =br.readLine();
        }
        br.close();
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str = br.readLine(); str br.readLine() br.readLine br while(str != null){
            String[] line = str.split("\\s");
            int H = Integer.parseInt(line[0]);
            int W = Integer.parseInt(line[1]);
            //System.out.println(H);
            //System.out.println(W);

            if(H ==0 && W == 0){
                break;
            }else{
                String TB = createTB(W);
                String IW = createIW(W);
                
                System.out.println(TB);
                for(int i=0;i<H-2;i++){
                    System.out.println(IW);
                }
                System.out.println(TB);
                System.out.println("");
            }
            str =br.readLine();
        } str != null str null {
            String[] line = str.split("\\s");
            int H = Integer.parseInt(line[0]);
            int W = Integer.parseInt(line[1]);
            //System.out.println(H);
            //System.out.println(W);

            if(H ==0 && W == 0){
                break;
            }else{
                String TB = createTB(W);
                String IW = createIW(W);
                
                System.out.println(TB);
                for(int i=0;i<H-2;i++){
                    System.out.println(IW);
                }
                System.out.println(TB);
                System.out.println("");
            }
            str =br.readLine();
        } String[] line = str.split("\\s"); line str.split("\\s") str.split str "\\s" int H = Integer.parseInt(line[0]); H Integer.parseInt(line[0]) Integer.parseInt Integer line[0] line 0 int W = Integer.parseInt(line[1]); W Integer.parseInt(line[1]) Integer.parseInt Integer line[1] line 1 if(H ==0 && W == 0){
                break;
            }else{
                String TB = createTB(W);
                String IW = createIW(W);
                
                System.out.println(TB);
                for(int i=0;i<H-2;i++){
                    System.out.println(IW);
                }
                System.out.println(TB);
                System.out.println("");
            } H ==0 && W == 0 H ==0 H 0 W == 0 W 0 {
                break;
            } break; {
                String TB = createTB(W);
                String IW = createIW(W);
                
                System.out.println(TB);
                for(int i=0;i<H-2;i++){
                    System.out.println(IW);
                }
                System.out.println(TB);
                System.out.println("");
            } String TB = createTB(W); TB createTB(W) createTB W String IW = createIW(W); IW createIW(W) createIW W System.out.println(TB) System.out.println System.out System System.out TB for(int i=0;i<H-2;i++){
                    System.out.println(IW);
                } int i=0; int i=0; i 0 i<H-2 i H-2 H 2 i++ i++ i {
                    System.out.println(IW);
                } {
                    System.out.println(IW);
                } System.out.println(IW) System.out.println System.out System System.out IW System.out.println(TB) System.out.println System.out System System.out TB System.out.println("") System.out.println System.out System System.out "" str =br.readLine() str br.readLine() br.readLine br br.close() br.close br String[] args args public static String createTB(int W){
        String temp ="";
        for(int i =0;i<W;i++){
            temp +="#";
        }
        return temp;
    } createTB {
        String temp ="";
        for(int i =0;i<W;i++){
            temp +="#";
        }
        return temp;
    } String temp =""; temp "" for(int i =0;i<W;i++){
            temp +="#";
        } int i =0; int i =0; i 0 i<W i W i++ i++ i {
            temp +="#";
        } {
            temp +="#";
        } temp +="#" temp "#" return temp; temp int W W public static String createIW(int W){
        StringBuilder temp = new StringBuilder();
            temp.append("#");
            for(int i=0;i<W-2;i++){
                temp.append(".");
            }
                temp.append("#");
                return temp.toString();
        } createIW {
        StringBuilder temp = new StringBuilder();
            temp.append("#");
            for(int i=0;i<W-2;i++){
                temp.append(".");
            }
                temp.append("#");
                return temp.toString();
        } StringBuilder temp = new StringBuilder(); temp new StringBuilder() temp.append("#") temp.append temp "#" for(int i=0;i<W-2;i++){
                temp.append(".");
            } int i=0; int i=0; i 0 i<W-2 i W-2 W 2 i++ i++ i {
                temp.append(".");
            } {
                temp.append(".");
            } temp.append(".") temp.append temp "." temp.append("#") temp.append temp "#" return temp.toString(); temp.toString() temp.toString temp int W W public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String str = br.readLine();
        
        while(str != null){
            String[] line = str.split("\\s");
            int H = Integer.parseInt(line[0]);
            int W = Integer.parseInt(line[1]);
            //System.out.println(H);
            //System.out.println(W);

            if(H ==0 && W == 0){
                break;
            }else{
                String TB = createTB(W);
                String IW = createIW(W);
                
                System.out.println(TB);
                for(int i=0;i<H-2;i++){
                    System.out.println(IW);
                }
                System.out.println(TB);
                System.out.println("");
            }
            str =br.readLine();
        }
        br.close();
    }

    public static String createTB(int W){
        String temp ="";
        for(int i =0;i<W;i++){
            temp +="#";
        }
        return temp;
    }
    
    public static String createIW(int W){
        StringBuilder temp = new StringBuilder();
            temp.append("#");
            for(int i=0;i<W-2;i++){
                temp.append(".");
            }
                temp.append("#");
                return temp.toString();
        }
} public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String str = br.readLine();
        
        while(str != null){
            String[] line = str.split("\\s");
            int H = Integer.parseInt(line[0]);
            int W = Integer.parseInt(line[1]);
            //System.out.println(H);
            //System.out.println(W);

            if(H ==0 && W == 0){
                break;
            }else{
                String TB = createTB(W);
                String IW = createIW(W);
                
                System.out.println(TB);
                for(int i=0;i<H-2;i++){
                    System.out.println(IW);
                }
                System.out.println(TB);
                System.out.println("");
            }
            str =br.readLine();
        }
        br.close();
    }

    public static String createTB(int W){
        String temp ="";
        for(int i =0;i<W;i++){
            temp +="#";
        }
        return temp;
    }
    
    public static String createIW(int W){
        StringBuilder temp = new StringBuilder();
            temp.append("#");
            for(int i=0;i<W-2;i++){
                temp.append(".");
            }
                temp.append("#");
                return temp.toString();
        }
} Main
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String str = br.readLine();
        
        while(str != null){
            String[] line = str.split("\\s");
            int H = Integer.parseInt(line[0]);
            int W = Integer.parseInt(line[1]);
            //System.out.println(H);
            //System.out.println(W);

            if(H ==0 && W == 0){
                break;
            }else{
                String TB = createTB(W);
                String IW = createIW(W);
                
                System.out.println(TB);
                for(int i=0;i<H-2;i++){
                    System.out.println(IW);
                }
                System.out.println(TB);
                System.out.println("");
            }
            str =br.readLine();
        }
        br.close();
    }

    public static String createTB(int W){
        String temp ="";
        for(int i =0;i<W;i++){
            temp +="#";
        }
        return temp;
    }
    
    public static String createIW(int W){
        StringBuilder temp = new StringBuilder();
            temp.append("#");
            for(int i=0;i<W-2;i++){
                temp.append(".");
            }
                temp.append("#");
                return temp.toString();
        }
}