import java.io.*;

public class Main{
    public static void main(String[]args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String crlf = System.getProperty("line.separator");
       
    
        
        while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
           
            if(h==0 && w==0){
                break;
            }else{
               
                for(int i=0;i<w;i++){
                   System.out.print("#"); //底辺
               }
               
               System.out.println();
               
               for(int i=0;i<h-2;i++){
                    System.out.print("#");
                    for(int j=0;j<w-2;j++){
                        System.out.print(".");
                    }
                    System.out.print("#");    
                    System.out.println();
               }
               
               for(int i=0;i<w;i++){
                   System.out.print("#"); //上辺
               }
               System.out.println();
            }
            System.out.println();
            
        }
        
        
        
        
    }
} import java.io.*; io.* java public class Main{
    public static void main(String[]args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String crlf = System.getProperty("line.separator");
       
    
        
        while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
           
            if(h==0 && w==0){
                break;
            }else{
               
                for(int i=0;i<w;i++){
                   System.out.print("#"); //底辺
               }
               
               System.out.println();
               
               for(int i=0;i<h-2;i++){
                    System.out.print("#");
                    for(int j=0;j<w-2;j++){
                        System.out.print(".");
                    }
                    System.out.print("#");    
                    System.out.println();
               }
               
               for(int i=0;i<w;i++){
                   System.out.print("#"); //上辺
               }
               System.out.println();
            }
            System.out.println();
            
        }
        
        
        
        
    }
} Main public static void main(String[]args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String crlf = System.getProperty("line.separator");
       
    
        
        while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
           
            if(h==0 && w==0){
                break;
            }else{
               
                for(int i=0;i<w;i++){
                   System.out.print("#"); //底辺
               }
               
               System.out.println();
               
               for(int i=0;i<h-2;i++){
                    System.out.print("#");
                    for(int j=0;j<w-2;j++){
                        System.out.print(".");
                    }
                    System.out.print("#");    
                    System.out.println();
               }
               
               for(int i=0;i<w;i++){
                   System.out.print("#"); //上辺
               }
               System.out.println();
            }
            System.out.println();
            
        }
        
        
        
        
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String crlf = System.getProperty("line.separator");
       
    
        
        while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
           
            if(h==0 && w==0){
                break;
            }else{
               
                for(int i=0;i<w;i++){
                   System.out.print("#"); //底辺
               }
               
               System.out.println();
               
               for(int i=0;i<h-2;i++){
                    System.out.print("#");
                    for(int j=0;j<w-2;j++){
                        System.out.print(".");
                    }
                    System.out.print("#");    
                    System.out.println();
               }
               
               for(int i=0;i<w;i++){
                   System.out.print("#"); //上辺
               }
               System.out.println();
            }
            System.out.println();
            
        }
        
        
        
        
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String crlf = System.getProperty("line.separator"); crlf System.getProperty("line.separator") System.getProperty System "line.separator" while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
           
            if(h==0 && w==0){
                break;
            }else{
               
                for(int i=0;i<w;i++){
                   System.out.print("#"); //底辺
               }
               
               System.out.println();
               
               for(int i=0;i<h-2;i++){
                    System.out.print("#");
                    for(int j=0;j<w-2;j++){
                        System.out.print(".");
                    }
                    System.out.print("#");    
                    System.out.println();
               }
               
               for(int i=0;i<w;i++){
                   System.out.print("#"); //上辺
               }
               System.out.println();
            }
            System.out.println();
            
        } true {
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
           
            if(h==0 && w==0){
                break;
            }else{
               
                for(int i=0;i<w;i++){
                   System.out.print("#"); //底辺
               }
               
               System.out.println();
               
               for(int i=0;i<h-2;i++){
                    System.out.print("#");
                    for(int j=0;j<w-2;j++){
                        System.out.print(".");
                    }
                    System.out.print("#");    
                    System.out.println();
               }
               
               for(int i=0;i<w;i++){
                   System.out.print("#"); //上辺
               }
               System.out.println();
            }
            System.out.println();
            
        } String[] str = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int h = Integer.parseInt(str[0]); h Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int w = Integer.parseInt(str[1]); w Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 if(h==0 && w==0){
                break;
            }else{
               
                for(int i=0;i<w;i++){
                   System.out.print("#"); //底辺
               }
               
               System.out.println();
               
               for(int i=0;i<h-2;i++){
                    System.out.print("#");
                    for(int j=0;j<w-2;j++){
                        System.out.print(".");
                    }
                    System.out.print("#");    
                    System.out.println();
               }
               
               for(int i=0;i<w;i++){
                   System.out.print("#"); //上辺
               }
               System.out.println();
            } h==0 && w==0 h==0 h 0 w==0 w 0 {
                break;
            } break; {
               
                for(int i=0;i<w;i++){
                   System.out.print("#"); //底辺
               }
               
               System.out.println();
               
               for(int i=0;i<h-2;i++){
                    System.out.print("#");
                    for(int j=0;j<w-2;j++){
                        System.out.print(".");
                    }
                    System.out.print("#");    
                    System.out.println();
               }
               
               for(int i=0;i<w;i++){
                   System.out.print("#"); //上辺
               }
               System.out.println();
            } 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.println() System.out.println System.out System System.out for(int i=0;i<h-2;i++){
                    System.out.print("#");
                    for(int j=0;j<w-2;j++){
                        System.out.print(".");
                    }
                    System.out.print("#");    
                    System.out.println();
               } int i=0; int i=0; i 0 i<h-2 i h-2 h 2 i++ i++ i {
                    System.out.print("#");
                    for(int j=0;j<w-2;j++){
                        System.out.print(".");
                    }
                    System.out.print("#");    
                    System.out.println();
               } {
                    System.out.print("#");
                    for(int j=0;j<w-2;j++){
                        System.out.print(".");
                    }
                    System.out.print("#");    
                    System.out.println();
               } System.out.print("#") System.out.print System.out System System.out "#" for(int j=0;j<w-2;j++){
                        System.out.print(".");
                    } int j=0; int j=0; j 0 j<w-2 j w-2 w 2 j++ j++ j {
                        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.println() System.out.println System.out System System.out 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.println() System.out.println System.out System System.out System.out.println() System.out.println System.out System System.out String[]args args public class Main{
    public static void main(String[]args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String crlf = System.getProperty("line.separator");
       
    
        
        while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
           
            if(h==0 && w==0){
                break;
            }else{
               
                for(int i=0;i<w;i++){
                   System.out.print("#"); //底辺
               }
               
               System.out.println();
               
               for(int i=0;i<h-2;i++){
                    System.out.print("#");
                    for(int j=0;j<w-2;j++){
                        System.out.print(".");
                    }
                    System.out.print("#");    
                    System.out.println();
               }
               
               for(int i=0;i<w;i++){
                   System.out.print("#"); //上辺
               }
               System.out.println();
            }
            System.out.println();
            
        }
        
        
        
        
    }
} public class Main{
    public static void main(String[]args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String crlf = System.getProperty("line.separator");
       
    
        
        while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
           
            if(h==0 && w==0){
                break;
            }else{
               
                for(int i=0;i<w;i++){
                   System.out.print("#"); //底辺
               }
               
               System.out.println();
               
               for(int i=0;i<h-2;i++){
                    System.out.print("#");
                    for(int j=0;j<w-2;j++){
                        System.out.print(".");
                    }
                    System.out.print("#");    
                    System.out.println();
               }
               
               for(int i=0;i<w;i++){
                   System.out.print("#"); //上辺
               }
               System.out.println();
            }
            System.out.println();
            
        }
        
        
        
        
    }
} Main
import java.io.*;

public class Main{
    public static void main(String[]args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String crlf = System.getProperty("line.separator");
       
    
        
        while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
           
            if(h==0 && w==0){
                break;
            }else{
               
                for(int i=0;i<w;i++){
                   System.out.print("#"); //底辺
               }
               
               System.out.println();
               
               for(int i=0;i<h-2;i++){
                    System.out.print("#");
                    for(int j=0;j<w-2;j++){
                        System.out.print(".");
                    }
                    System.out.print("#");    
                    System.out.println();
               }
               
               for(int i=0;i<w;i++){
                   System.out.print("#"); //上辺
               }
               System.out.println();
            }
            System.out.println();
            
        }
        
        
        
        
    }
}