import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        for(;;){
            int H = scan.nextInt();
            int W = scan.nextInt();
            if(H != 0 && W != 0){
                for(int i = 1; i <= H; i++){
                    System.out.print("#");
                    if(i != 1 && i != H){
                        for(int j = 1; j < W; j++){
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        }
                    }else{
                        for(int j = 1; j < W; j++){
                            System.out.print("#");
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            }else{
                break;
            }
        }    
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        for(;;){
            int H = scan.nextInt();
            int W = scan.nextInt();
            if(H != 0 && W != 0){
                for(int i = 1; i <= H; i++){
                    System.out.print("#");
                    if(i != 1 && i != H){
                        for(int j = 1; j < W; j++){
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        }
                    }else{
                        for(int j = 1; j < W; j++){
                            System.out.print("#");
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            }else{
                break;
            }
        }    
    }
} Main public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        for(;;){
            int H = scan.nextInt();
            int W = scan.nextInt();
            if(H != 0 && W != 0){
                for(int i = 1; i <= H; i++){
                    System.out.print("#");
                    if(i != 1 && i != H){
                        for(int j = 1; j < W; j++){
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        }
                    }else{
                        for(int j = 1; j < W; j++){
                            System.out.print("#");
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            }else{
                break;
            }
        }    
    } main {
        Scanner scan = new java.util.Scanner(System.in);
        for(;;){
            int H = scan.nextInt();
            int W = scan.nextInt();
            if(H != 0 && W != 0){
                for(int i = 1; i <= H; i++){
                    System.out.print("#");
                    if(i != 1 && i != H){
                        for(int j = 1; j < W; j++){
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        }
                    }else{
                        for(int j = 1; j < W; j++){
                            System.out.print("#");
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            }else{
                break;
            }
        }    
    } Scanner scan = new java.util.Scanner(System.in); scan new java.util.Scanner(System.in) for(;;){
            int H = scan.nextInt();
            int W = scan.nextInt();
            if(H != 0 && W != 0){
                for(int i = 1; i <= H; i++){
                    System.out.print("#");
                    if(i != 1 && i != H){
                        for(int j = 1; j < W; j++){
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        }
                    }else{
                        for(int j = 1; j < W; j++){
                            System.out.print("#");
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            }else{
                break;
            }
        } ; {
            int H = scan.nextInt();
            int W = scan.nextInt();
            if(H != 0 && W != 0){
                for(int i = 1; i <= H; i++){
                    System.out.print("#");
                    if(i != 1 && i != H){
                        for(int j = 1; j < W; j++){
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        }
                    }else{
                        for(int j = 1; j < W; j++){
                            System.out.print("#");
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            }else{
                break;
            }
        } {
            int H = scan.nextInt();
            int W = scan.nextInt();
            if(H != 0 && W != 0){
                for(int i = 1; i <= H; i++){
                    System.out.print("#");
                    if(i != 1 && i != H){
                        for(int j = 1; j < W; j++){
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        }
                    }else{
                        for(int j = 1; j < W; j++){
                            System.out.print("#");
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            }else{
                break;
            }
        } int H = scan.nextInt(); H scan.nextInt() scan.nextInt scan int W = scan.nextInt(); W scan.nextInt() scan.nextInt scan if(H != 0 && W != 0){
                for(int i = 1; i <= H; i++){
                    System.out.print("#");
                    if(i != 1 && i != H){
                        for(int j = 1; j < W; j++){
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        }
                    }else{
                        for(int j = 1; j < W; j++){
                            System.out.print("#");
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            }else{
                break;
            } H != 0 && W != 0 H != 0 H 0 W != 0 W 0 {
                for(int i = 1; i <= H; i++){
                    System.out.print("#");
                    if(i != 1 && i != H){
                        for(int j = 1; j < W; j++){
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        }
                    }else{
                        for(int j = 1; j < W; j++){
                            System.out.print("#");
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            } for(int i = 1; i <= H; i++){
                    System.out.print("#");
                    if(i != 1 && i != H){
                        for(int j = 1; j < W; j++){
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        }
                    }else{
                        for(int j = 1; j < W; j++){
                            System.out.print("#");
                        }
                    }
                    System.out.println();
                } int i = 1; int i = 1; i 1 i <= H i H i++ i++ i {
                    System.out.print("#");
                    if(i != 1 && i != H){
                        for(int j = 1; j < W; j++){
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        }
                    }else{
                        for(int j = 1; j < W; j++){
                            System.out.print("#");
                        }
                    }
                    System.out.println();
                } {
                    System.out.print("#");
                    if(i != 1 && i != H){
                        for(int j = 1; j < W; j++){
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        }
                    }else{
                        for(int j = 1; j < W; j++){
                            System.out.print("#");
                        }
                    }
                    System.out.println();
                } System.out.print("#") System.out.print System.out System System.out "#" if(i != 1 && i != H){
                        for(int j = 1; j < W; j++){
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        }
                    }else{
                        for(int j = 1; j < W; j++){
                            System.out.print("#");
                        }
                    } i != 1 && i != H i != 1 i 1 i != H i H {
                        for(int j = 1; j < W; j++){
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        }
                    } for(int j = 1; j < W; j++){
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        } int j = 1; int j = 1; j 1 j < W j W j++ j++ j {
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        } {
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        } if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } j != W - 1 j 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 "#" {
                        for(int j = 1; j < W; j++){
                            System.out.print("#");
                        }
                    } for(int j = 1; j < W; j++){
                            System.out.print("#");
                        } int j = 1; int j = 1; j 1 j < W j W j++ j++ j {
                            System.out.print("#");
                        } {
                            System.out.print("#");
                        } System.out.print("#") System.out.print System.out System System.out "#" System.out.println() System.out.println System.out System System.out System.out.println() System.out.println System.out System System.out {
                break;
            } break; String[] args args public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        for(;;){
            int H = scan.nextInt();
            int W = scan.nextInt();
            if(H != 0 && W != 0){
                for(int i = 1; i <= H; i++){
                    System.out.print("#");
                    if(i != 1 && i != H){
                        for(int j = 1; j < W; j++){
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        }
                    }else{
                        for(int j = 1; j < W; j++){
                            System.out.print("#");
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            }else{
                break;
            }
        }    
    }
} public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        for(;;){
            int H = scan.nextInt();
            int W = scan.nextInt();
            if(H != 0 && W != 0){
                for(int i = 1; i <= H; i++){
                    System.out.print("#");
                    if(i != 1 && i != H){
                        for(int j = 1; j < W; j++){
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        }
                    }else{
                        for(int j = 1; j < W; j++){
                            System.out.print("#");
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            }else{
                break;
            }
        }    
    }
} Main
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        for(;;){
            int H = scan.nextInt();
            int W = scan.nextInt();
            if(H != 0 && W != 0){
                for(int i = 1; i <= H; i++){
                    System.out.print("#");
                    if(i != 1 && i != H){
                        for(int j = 1; j < W; j++){
                            if(j != W - 1){
                                System.out.print(".");
                            }else{
                                System.out.print("#");
                            } 
                        }
                    }else{
                        for(int j = 1; j < W; j++){
                            System.out.print("#");
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            }else{
                break;
            }
        }    
    }
}