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

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        
        while (H != 0 || W != 0) {
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (i == 0 || i == H-1 || j == 0 || j == W-1) {
                        System.out.printf("#");
                    }
                    else {
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
            
            H = sc.nextInt();
            W = sc.nextInt();
        }
    }
} import java.io.*; io.* java import java.util.*; util.* java class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        
        while (H != 0 || W != 0) {
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (i == 0 || i == H-1 || j == 0 || j == W-1) {
                        System.out.printf("#");
                    }
                    else {
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
            
            H = sc.nextInt();
            W = sc.nextInt();
        }
    }
} Main public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        
        while (H != 0 || W != 0) {
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (i == 0 || i == H-1 || j == 0 || j == W-1) {
                        System.out.printf("#");
                    }
                    else {
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
            
            H = sc.nextInt();
            W = sc.nextInt();
        }
    } main {
        Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        
        while (H != 0 || W != 0) {
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (i == 0 || i == H-1 || j == 0 || j == W-1) {
                        System.out.printf("#");
                    }
                    else {
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
            
            H = sc.nextInt();
            W = sc.nextInt();
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int H = sc.nextInt(); H sc.nextInt() sc.nextInt sc int W = sc.nextInt(); W sc.nextInt() sc.nextInt sc while (H != 0 || W != 0) {
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (i == 0 || i == H-1 || j == 0 || j == W-1) {
                        System.out.printf("#");
                    }
                    else {
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
            
            H = sc.nextInt();
            W = sc.nextInt();
        } H != 0 || W != 0 H != 0 H 0 W != 0 W 0 {
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (i == 0 || i == H-1 || j == 0 || j == W-1) {
                        System.out.printf("#");
                    }
                    else {
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
            
            H = sc.nextInt();
            W = sc.nextInt();
        } for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (i == 0 || i == H-1 || j == 0 || j == W-1) {
                        System.out.printf("#");
                    }
                    else {
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            } int i = 0; int i = 0; i 0 i < H i H i++ i++ i {
                for (int j = 0; j < W; j++) {
                    if (i == 0 || i == H-1 || j == 0 || j == W-1) {
                        System.out.printf("#");
                    }
                    else {
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            } {
                for (int j = 0; j < W; j++) {
                    if (i == 0 || i == H-1 || j == 0 || j == W-1) {
                        System.out.printf("#");
                    }
                    else {
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            } for (int j = 0; j < W; j++) {
                    if (i == 0 || i == H-1 || j == 0 || j == W-1) {
                        System.out.printf("#");
                    }
                    else {
                        System.out.printf(".");
                    }
                } int j = 0; int j = 0; j 0 j < W j W j++ j++ j {
                    if (i == 0 || i == H-1 || j == 0 || j == W-1) {
                        System.out.printf("#");
                    }
                    else {
                        System.out.printf(".");
                    }
                } {
                    if (i == 0 || i == H-1 || j == 0 || j == W-1) {
                        System.out.printf("#");
                    }
                    else {
                        System.out.printf(".");
                    }
                } if (i == 0 || i == H-1 || j == 0 || j == W-1) {
                        System.out.printf("#");
                    }
                    else {
                        System.out.printf(".");
                    } i == 0 || i == H-1 || j == 0 || j == W-1 j == 0 i == 0 || i == H-1 || j == 0 || j == W-1 i == 0 i 0 i == H-1 i H-1 H 1 j == 0 j 0 j == W-1 j W-1 W 1 {
                        System.out.printf("#");
                    } System.out.printf("#") System.out.printf System.out System System.out "#" {
                        System.out.printf(".");
                    } System.out.printf(".") System.out.printf System.out System System.out "." System.out.printf("\n") System.out.printf System.out System System.out "\n" System.out.printf("\n") System.out.printf System.out System System.out "\n" H = sc.nextInt() H sc.nextInt() sc.nextInt sc W = sc.nextInt() W sc.nextInt() sc.nextInt sc String[] args args
import java.io.*;
import java.util.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        
        while (H != 0 || W != 0) {
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (i == 0 || i == H-1 || j == 0 || j == W-1) {
                        System.out.printf("#");
                    }
                    else {
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
            
            H = sc.nextInt();
            W = sc.nextInt();
        }
    }
}