/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author otsuhata
 */
import java.util.Scanner;

public class Main{
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        //System.out.println("???H * ?¨?W ?????§???????????????????????????????????°????????§??????");
        //System.out.println("H??¨W?????????3??????300?????????????????\????????????????????????");
        
        for(int i = 0; i < 3000; i ++) {
            //System.out.print("??????????§????????????????????????§??\?????????????????????(0 0??§???????????????):");
            int H = sc.nextInt();
            int W = sc.nextInt();
            
            if(printJudge(H,W)) {
                printUpBtm(W);
                
                for(int height = 0; height < (H - 2) ; height++) {
                    printFrame(W);
                }
                
                printUpBtm(W);
            }else {
                //System.out.println("##### GAME OVER #####");
                break;
            }
            
            //printUpBtm(W);
            
            System.out.print("\n");
        }
    }    

    public static void printFrame(int W) { 
        System.out.print("#"); 
	for(int i = 0; i < (W - 2); i++) {
		System.out.print(".");                
	}
        System.out.print("#"); 
        System.out.print("\n");    
    }
    
     public static void printUpBtm(int W) {  
	for(int i = 0; i < W; i++) {
		System.out.print("#");                
	}
        System.out.print("\n");    
    }
    
    
    public static boolean printJudge(int H, int W) {
        if((H == 0 && W == 0)) {
            return false;
        }else return !(H < 3 || H > 300 || W < 3 || W > 300);
    }
    
} import java.util.Scanner; Scanner java.util public class Main{
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        //System.out.println("???H * ?¨?W ?????§???????????????????????????????????°????????§??????");
        //System.out.println("H??¨W?????????3??????300?????????????????\????????????????????????");
        
        for(int i = 0; i < 3000; i ++) {
            //System.out.print("??????????§????????????????????????§??\?????????????????????(0 0??§???????????????):");
            int H = sc.nextInt();
            int W = sc.nextInt();
            
            if(printJudge(H,W)) {
                printUpBtm(W);
                
                for(int height = 0; height < (H - 2) ; height++) {
                    printFrame(W);
                }
                
                printUpBtm(W);
            }else {
                //System.out.println("##### GAME OVER #####");
                break;
            }
            
            //printUpBtm(W);
            
            System.out.print("\n");
        }
    }    

    public static void printFrame(int W) { 
        System.out.print("#"); 
	for(int i = 0; i < (W - 2); i++) {
		System.out.print(".");                
	}
        System.out.print("#"); 
        System.out.print("\n");    
    }
    
     public static void printUpBtm(int W) {  
	for(int i = 0; i < W; i++) {
		System.out.print("#");                
	}
        System.out.print("\n");    
    }
    
    
    public static boolean printJudge(int H, int W) {
        if((H == 0 && W == 0)) {
            return false;
        }else return !(H < 3 || H > 300 || W < 3 || W > 300);
    }
    
} Main public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        //System.out.println("???H * ?¨?W ?????§???????????????????????????????????°????????§??????");
        //System.out.println("H??¨W?????????3??????300?????????????????\????????????????????????");
        
        for(int i = 0; i < 3000; i ++) {
            //System.out.print("??????????§????????????????????????§??\?????????????????????(0 0??§???????????????):");
            int H = sc.nextInt();
            int W = sc.nextInt();
            
            if(printJudge(H,W)) {
                printUpBtm(W);
                
                for(int height = 0; height < (H - 2) ; height++) {
                    printFrame(W);
                }
                
                printUpBtm(W);
            }else {
                //System.out.println("##### GAME OVER #####");
                break;
            }
            
            //printUpBtm(W);
            
            System.out.print("\n");
        }
    } main {
        
        Scanner sc = new Scanner(System.in);
        
        //System.out.println("???H * ?¨?W ?????§???????????????????????????????????°????????§??????");
        //System.out.println("H??¨W?????????3??????300?????????????????\????????????????????????");
        
        for(int i = 0; i < 3000; i ++) {
            //System.out.print("??????????§????????????????????????§??\?????????????????????(0 0??§???????????????):");
            int H = sc.nextInt();
            int W = sc.nextInt();
            
            if(printJudge(H,W)) {
                printUpBtm(W);
                
                for(int height = 0; height < (H - 2) ; height++) {
                    printFrame(W);
                }
                
                printUpBtm(W);
            }else {
                //System.out.println("##### GAME OVER #####");
                break;
            }
            
            //printUpBtm(W);
            
            System.out.print("\n");
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) for(int i = 0; i < 3000; i ++) {
            //System.out.print("??????????§????????????????????????§??\?????????????????????(0 0??§???????????????):");
            int H = sc.nextInt();
            int W = sc.nextInt();
            
            if(printJudge(H,W)) {
                printUpBtm(W);
                
                for(int height = 0; height < (H - 2) ; height++) {
                    printFrame(W);
                }
                
                printUpBtm(W);
            }else {
                //System.out.println("##### GAME OVER #####");
                break;
            }
            
            //printUpBtm(W);
            
            System.out.print("\n");
        } int i = 0; int i = 0; i 0 i < 3000 i 3000 i ++ i ++ i {
            //System.out.print("??????????§????????????????????????§??\?????????????????????(0 0??§???????????????):");
            int H = sc.nextInt();
            int W = sc.nextInt();
            
            if(printJudge(H,W)) {
                printUpBtm(W);
                
                for(int height = 0; height < (H - 2) ; height++) {
                    printFrame(W);
                }
                
                printUpBtm(W);
            }else {
                //System.out.println("##### GAME OVER #####");
                break;
            }
            
            //printUpBtm(W);
            
            System.out.print("\n");
        } {
            //System.out.print("??????????§????????????????????????§??\?????????????????????(0 0??§???????????????):");
            int H = sc.nextInt();
            int W = sc.nextInt();
            
            if(printJudge(H,W)) {
                printUpBtm(W);
                
                for(int height = 0; height < (H - 2) ; height++) {
                    printFrame(W);
                }
                
                printUpBtm(W);
            }else {
                //System.out.println("##### GAME OVER #####");
                break;
            }
            
            //printUpBtm(W);
            
            System.out.print("\n");
        } int H = sc.nextInt(); H sc.nextInt() sc.nextInt sc int W = sc.nextInt(); W sc.nextInt() sc.nextInt sc if(printJudge(H,W)) {
                printUpBtm(W);
                
                for(int height = 0; height < (H - 2) ; height++) {
                    printFrame(W);
                }
                
                printUpBtm(W);
            }else {
                //System.out.println("##### GAME OVER #####");
                break;
            } printJudge(H,W) printJudge H W {
                printUpBtm(W);
                
                for(int height = 0; height < (H - 2) ; height++) {
                    printFrame(W);
                }
                
                printUpBtm(W);
            } printUpBtm(W) printUpBtm W for(int height = 0; height < (H - 2) ; height++) {
                    printFrame(W);
                } int height = 0; int height = 0; height 0 height < (H - 2) height (H - 2) H 2 height++ height++ height {
                    printFrame(W);
                } {
                    printFrame(W);
                } printFrame(W) printFrame W printUpBtm(W) printUpBtm W {
                //System.out.println("##### GAME OVER #####");
                break;
            } break; System.out.print("\n") System.out.print System.out System System.out "\n" String[] args args public static void printFrame(int W) { 
        System.out.print("#"); 
	for(int i = 0; i < (W - 2); i++) {
		System.out.print(".");                
	}
        System.out.print("#"); 
        System.out.print("\n");    
    } printFrame { 
        System.out.print("#"); 
	for(int i = 0; i < (W - 2); i++) {
		System.out.print(".");                
	}
        System.out.print("#"); 
        System.out.print("\n");    
    } System.out.print("#") System.out.print System.out System System.out "#" for(int i = 0; i < (W - 2); i++) {
		System.out.print(".");                
	} int i = 0; int i = 0; i 0 i < (W - 2) i (W - 2) W 2 i++ i++ i {
		System.out.print(".");                
	} {
		System.out.print(".");                
	} System.out.print(".") System.out.print System.out System System.out "." 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 W W public static void printUpBtm(int W) {  
	for(int i = 0; i < W; i++) {
		System.out.print("#");                
	}
        System.out.print("\n");    
    } printUpBtm {  
	for(int i = 0; i < W; i++) {
		System.out.print("#");                
	}
        System.out.print("\n");    
    } for(int i = 0; i < W; i++) {
		System.out.print("#");                
	} int i = 0; int i = 0; i 0 i < W i W i++ i++ i {
		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 W W public static boolean printJudge(int H, int W) {
        if((H == 0 && W == 0)) {
            return false;
        }else return !(H < 3 || H > 300 || W < 3 || W > 300);
    } printJudge {
        if((H == 0 && W == 0)) {
            return false;
        }else return !(H < 3 || H > 300 || W < 3 || W > 300);
    } if((H == 0 && W == 0)) {
            return false;
        }else return !(H < 3 || H > 300 || W < 3 || W > 300); (H == 0 && W == 0) H == 0 H 0 W == 0 W 0 {
            return false;
        } return false; false return !(H < 3 || H > 300 || W < 3 || W > 300); !(H < 3 || H > 300 || W < 3 || W > 300) (H < 3 || H > 300 || W < 3 || W > 300) W < 3 H < 3 || H > 300 || W < 3 || W > 300 H < 3 H 3 H > 300 H 300 W < 3 W 3 W > 300 W 300 int H H int W W public class Main{
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        //System.out.println("???H * ?¨?W ?????§???????????????????????????????????°????????§??????");
        //System.out.println("H??¨W?????????3??????300?????????????????\????????????????????????");
        
        for(int i = 0; i < 3000; i ++) {
            //System.out.print("??????????§????????????????????????§??\?????????????????????(0 0??§???????????????):");
            int H = sc.nextInt();
            int W = sc.nextInt();
            
            if(printJudge(H,W)) {
                printUpBtm(W);
                
                for(int height = 0; height < (H - 2) ; height++) {
                    printFrame(W);
                }
                
                printUpBtm(W);
            }else {
                //System.out.println("##### GAME OVER #####");
                break;
            }
            
            //printUpBtm(W);
            
            System.out.print("\n");
        }
    }    

    public static void printFrame(int W) { 
        System.out.print("#"); 
	for(int i = 0; i < (W - 2); i++) {
		System.out.print(".");                
	}
        System.out.print("#"); 
        System.out.print("\n");    
    }
    
     public static void printUpBtm(int W) {  
	for(int i = 0; i < W; i++) {
		System.out.print("#");                
	}
        System.out.print("\n");    
    }
    
    
    public static boolean printJudge(int H, int W) {
        if((H == 0 && W == 0)) {
            return false;
        }else return !(H < 3 || H > 300 || W < 3 || W > 300);
    }
    
} public class Main{
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        //System.out.println("???H * ?¨?W ?????§???????????????????????????????????°????????§??????");
        //System.out.println("H??¨W?????????3??????300?????????????????\????????????????????????");
        
        for(int i = 0; i < 3000; i ++) {
            //System.out.print("??????????§????????????????????????§??\?????????????????????(0 0??§???????????????):");
            int H = sc.nextInt();
            int W = sc.nextInt();
            
            if(printJudge(H,W)) {
                printUpBtm(W);
                
                for(int height = 0; height < (H - 2) ; height++) {
                    printFrame(W);
                }
                
                printUpBtm(W);
            }else {
                //System.out.println("##### GAME OVER #####");
                break;
            }
            
            //printUpBtm(W);
            
            System.out.print("\n");
        }
    }    

    public static void printFrame(int W) { 
        System.out.print("#"); 
	for(int i = 0; i < (W - 2); i++) {
		System.out.print(".");                
	}
        System.out.print("#"); 
        System.out.print("\n");    
    }
    
     public static void printUpBtm(int W) {  
	for(int i = 0; i < W; i++) {
		System.out.print("#");                
	}
        System.out.print("\n");    
    }
    
    
    public static boolean printJudge(int H, int W) {
        if((H == 0 && W == 0)) {
            return false;
        }else return !(H < 3 || H > 300 || W < 3 || W > 300);
    }
    
} Main
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author otsuhata
 */
import java.util.Scanner;

public class Main{
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        //System.out.println("???H * ?¨?W ?????§???????????????????????????????????°????????§??????");
        //System.out.println("H??¨W?????????3??????300?????????????????\????????????????????????");
        
        for(int i = 0; i < 3000; i ++) {
            //System.out.print("??????????§????????????????????????§??\?????????????????????(0 0??§???????????????):");
            int H = sc.nextInt();
            int W = sc.nextInt();
            
            if(printJudge(H,W)) {
                printUpBtm(W);
                
                for(int height = 0; height < (H - 2) ; height++) {
                    printFrame(W);
                }
                
                printUpBtm(W);
            }else {
                //System.out.println("##### GAME OVER #####");
                break;
            }
            
            //printUpBtm(W);
            
            System.out.print("\n");
        }
    }    

    public static void printFrame(int W) { 
        System.out.print("#"); 
	for(int i = 0; i < (W - 2); i++) {
		System.out.print(".");                
	}
        System.out.print("#"); 
        System.out.print("\n");    
    }
    
     public static void printUpBtm(int W) {  
	for(int i = 0; i < W; i++) {
		System.out.print("#");                
	}
        System.out.print("\n");    
    }
    
    
    public static boolean printJudge(int H, int W) {
        if((H == 0 && W == 0)) {
            return false;
        }else return !(H < 3 || H > 300 || W < 3 || W > 300);
    }
    
}