
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int h = scanner.nextInt();
        int w = scanner.nextInt();
        while (h + w > 0) {
            
            
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                   if(j==0||j==w-1||i==0||i==h-1)
                    System.out.print("#");
                   else
                   System.out.print("."); 
                   
                }
                System.out.println();
            }
            System.out.println();
            
            
            
            h = scanner.nextInt();
            w = scanner.nextInt();
        }
    }
}
 import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int h = scanner.nextInt();
        int w = scanner.nextInt();
        while (h + w > 0) {
            
            
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                   if(j==0||j==w-1||i==0||i==h-1)
                    System.out.print("#");
                   else
                   System.out.print("."); 
                   
                }
                System.out.println();
            }
            System.out.println();
            
            
            
            h = scanner.nextInt();
            w = scanner.nextInt();
        }
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int h = scanner.nextInt();
        int w = scanner.nextInt();
        while (h + w > 0) {
            
            
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                   if(j==0||j==w-1||i==0||i==h-1)
                    System.out.print("#");
                   else
                   System.out.print("."); 
                   
                }
                System.out.println();
            }
            System.out.println();
            
            
            
            h = scanner.nextInt();
            w = scanner.nextInt();
        }
    } main {
        Scanner scanner = new Scanner(System.in);

        int h = scanner.nextInt();
        int w = scanner.nextInt();
        while (h + w > 0) {
            
            
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                   if(j==0||j==w-1||i==0||i==h-1)
                    System.out.print("#");
                   else
                   System.out.print("."); 
                   
                }
                System.out.println();
            }
            System.out.println();
            
            
            
            h = scanner.nextInt();
            w = scanner.nextInt();
        }
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int h = scanner.nextInt(); h scanner.nextInt() scanner.nextInt scanner int w = scanner.nextInt(); w scanner.nextInt() scanner.nextInt scanner while (h + w > 0) {
            
            
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                   if(j==0||j==w-1||i==0||i==h-1)
                    System.out.print("#");
                   else
                   System.out.print("."); 
                   
                }
                System.out.println();
            }
            System.out.println();
            
            
            
            h = scanner.nextInt();
            w = scanner.nextInt();
        } h + w > 0 h + w h w 0 {
            
            
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                   if(j==0||j==w-1||i==0||i==h-1)
                    System.out.print("#");
                   else
                   System.out.print("."); 
                   
                }
                System.out.println();
            }
            System.out.println();
            
            
            
            h = scanner.nextInt();
            w = scanner.nextInt();
        } for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                   if(j==0||j==w-1||i==0||i==h-1)
                    System.out.print("#");
                   else
                   System.out.print("."); 
                   
                }
                System.out.println();
            } int i=0; int i=0; i 0 i<h i h i++ i++ i {
                for(int j=0; j<w; j++){
                   if(j==0||j==w-1||i==0||i==h-1)
                    System.out.print("#");
                   else
                   System.out.print("."); 
                   
                }
                System.out.println();
            } {
                for(int j=0; j<w; j++){
                   if(j==0||j==w-1||i==0||i==h-1)
                    System.out.print("#");
                   else
                   System.out.print("."); 
                   
                }
                System.out.println();
            } for(int j=0; j<w; j++){
                   if(j==0||j==w-1||i==0||i==h-1)
                    System.out.print("#");
                   else
                   System.out.print("."); 
                   
                } int j=0; int j=0; j 0 j<w j w j++ j++ j {
                   if(j==0||j==w-1||i==0||i==h-1)
                    System.out.print("#");
                   else
                   System.out.print("."); 
                   
                } {
                   if(j==0||j==w-1||i==0||i==h-1)
                    System.out.print("#");
                   else
                   System.out.print("."); 
                   
                } if(j==0||j==w-1||i==0||i==h-1)
                    System.out.print("#");
                   else
                   System.out.print("."); j==0||j==w-1||i==0||i==h-1 i==0 j==0||j==w-1||i==0||i==h-1 j==0 j 0 j==w-1 j w-1 w 1 i==0 i 0 i==h-1 i h-1 h 1 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 System.out.println() System.out.println System.out System System.out h = scanner.nextInt() h scanner.nextInt() scanner.nextInt scanner w = scanner.nextInt() w scanner.nextInt() scanner.nextInt scanner String[] args args public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int h = scanner.nextInt();
        int w = scanner.nextInt();
        while (h + w > 0) {
            
            
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                   if(j==0||j==w-1||i==0||i==h-1)
                    System.out.print("#");
                   else
                   System.out.print("."); 
                   
                }
                System.out.println();
            }
            System.out.println();
            
            
            
            h = scanner.nextInt();
            w = scanner.nextInt();
        }
    }
} public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int h = scanner.nextInt();
        int w = scanner.nextInt();
        while (h + w > 0) {
            
            
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                   if(j==0||j==w-1||i==0||i==h-1)
                    System.out.print("#");
                   else
                   System.out.print("."); 
                   
                }
                System.out.println();
            }
            System.out.println();
            
            
            
            h = scanner.nextInt();
            w = scanner.nextInt();
        }
    }
} Main

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int h = scanner.nextInt();
        int w = scanner.nextInt();
        while (h + w > 0) {
            
            
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                   if(j==0||j==w-1||i==0||i==h-1)
                    System.out.print("#");
                   else
                   System.out.print("."); 
                   
                }
                System.out.println();
            }
            System.out.println();
            
            
            
            h = scanner.nextInt();
            w = scanner.nextInt();
        }
    }
}

