import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int k = 0; k < W; k++) {
                System.out.printf("#");
            }
            System.out.printf("\n");
            for (int i = 0; i < H - 2; i++) {
                System.out.printf("#");
                for (int j = 0; j < W - 2; j++) {
                    System.out.printf(".");
                }
                System.out.printf("#\n");
            }
            for (int k = 0; k < W; k++) {
                System.out.printf("#");
            }
            System.out.printf("\n\n");
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int k = 0; k < W; k++) {
                System.out.printf("#");
            }
            System.out.printf("\n");
            for (int i = 0; i < H - 2; i++) {
                System.out.printf("#");
                for (int j = 0; j < W - 2; j++) {
                    System.out.printf(".");
                }
                System.out.printf("#\n");
            }
            for (int k = 0; k < W; k++) {
                System.out.printf("#");
            }
            System.out.printf("\n\n");
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int k = 0; k < W; k++) {
                System.out.printf("#");
            }
            System.out.printf("\n");
            for (int i = 0; i < H - 2; i++) {
                System.out.printf("#");
                for (int j = 0; j < W - 2; j++) {
                    System.out.printf(".");
                }
                System.out.printf("#\n");
            }
            for (int k = 0; k < W; k++) {
                System.out.printf("#");
            }
            System.out.printf("\n\n");
        }
    } main {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int k = 0; k < W; k++) {
                System.out.printf("#");
            }
            System.out.printf("\n");
            for (int i = 0; i < H - 2; i++) {
                System.out.printf("#");
                for (int j = 0; j < W - 2; j++) {
                    System.out.printf(".");
                }
                System.out.printf("#\n");
            }
            for (int k = 0; k < W; k++) {
                System.out.printf("#");
            }
            System.out.printf("\n\n");
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int k = 0; k < W; k++) {
                System.out.printf("#");
            }
            System.out.printf("\n");
            for (int i = 0; i < H - 2; i++) {
                System.out.printf("#");
                for (int j = 0; j < W - 2; j++) {
                    System.out.printf(".");
                }
                System.out.printf("#\n");
            }
            for (int k = 0; k < W; k++) {
                System.out.printf("#");
            }
            System.out.printf("\n\n");
        } true {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int k = 0; k < W; k++) {
                System.out.printf("#");
            }
            System.out.printf("\n");
            for (int i = 0; i < H - 2; i++) {
                System.out.printf("#");
                for (int j = 0; j < W - 2; j++) {
                    System.out.printf(".");
                }
                System.out.printf("#\n");
            }
            for (int k = 0; k < W; k++) {
                System.out.printf("#");
            }
            System.out.printf("\n\n");
        } int H = sc.nextInt(); H sc.nextInt() sc.nextInt sc int W = sc.nextInt(); W sc.nextInt() sc.nextInt sc if (H == 0 && W == 0) {
                break;
            } H == 0 && W == 0 H == 0 H 0 W == 0 W 0 {
                break;
            } break; for (int k = 0; k < W; k++) {
                System.out.printf("#");
            } int k = 0; int k = 0; k 0 k < W k W k++ k++ k {
                System.out.printf("#");
            } {
                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" for (int i = 0; i < H - 2; i++) {
                System.out.printf("#");
                for (int j = 0; j < W - 2; j++) {
                    System.out.printf(".");
                }
                System.out.printf("#\n");
            } int i = 0; int i = 0; i 0 i < H - 2 i H - 2 H 2 i++ i++ i {
                System.out.printf("#");
                for (int j = 0; j < W - 2; j++) {
                    System.out.printf(".");
                }
                System.out.printf("#\n");
            } {
                System.out.printf("#");
                for (int j = 0; j < W - 2; j++) {
                    System.out.printf(".");
                }
                System.out.printf("#\n");
            } System.out.printf("#") System.out.printf System.out System System.out "#" for (int j = 0; j < W - 2; j++) {
                    System.out.printf(".");
                } int j = 0; int j = 0; j 0 j < W - 2 j W - 2 W 2 j++ j++ j {
                    System.out.printf(".");
                } {
                    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" for (int k = 0; k < W; k++) {
                System.out.printf("#");
            } int k = 0; int k = 0; k 0 k < W k W k++ k++ k {
                System.out.printf("#");
            } {
                System.out.printf("#");
            } System.out.printf("#") System.out.printf System.out System System.out "#" System.out.printf("\n\n") System.out.printf System.out System System.out "\n\n" String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int k = 0; k < W; k++) {
                System.out.printf("#");
            }
            System.out.printf("\n");
            for (int i = 0; i < H - 2; i++) {
                System.out.printf("#");
                for (int j = 0; j < W - 2; j++) {
                    System.out.printf(".");
                }
                System.out.printf("#\n");
            }
            for (int k = 0; k < W; k++) {
                System.out.printf("#");
            }
            System.out.printf("\n\n");
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int k = 0; k < W; k++) {
                System.out.printf("#");
            }
            System.out.printf("\n");
            for (int i = 0; i < H - 2; i++) {
                System.out.printf("#");
                for (int j = 0; j < W - 2; j++) {
                    System.out.printf(".");
                }
                System.out.printf("#\n");
            }
            for (int k = 0; k < W; k++) {
                System.out.printf("#");
            }
            System.out.printf("\n\n");
        }
    }
} Main
import java.util.Scanner;

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