import java.util.Scanner;

public class Main {
    private static Scanner scan;

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

        while (true) {
            int x = scan.nextInt();
            int y = scan.nextInt();
            if (x == 0 && y == 0) {
                return;
            }
            for (int i = 0; i < x; i++) {
                for (int p = 0; p < y; p++) {
                    if (i == 0 || p == 0 || (i == x - 1) || (p == y - 1)) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    private static Scanner scan;

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

        while (true) {
            int x = scan.nextInt();
            int y = scan.nextInt();
            if (x == 0 && y == 0) {
                return;
            }
            for (int i = 0; i < x; i++) {
                for (int p = 0; p < y; p++) {
                    if (i == 0 || p == 0 || (i == x - 1) || (p == y - 1)) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
} Main private static Scanner scan; scan public static void main(String[] args) {
        scan = new Scanner(System.in);

        while (true) {
            int x = scan.nextInt();
            int y = scan.nextInt();
            if (x == 0 && y == 0) {
                return;
            }
            for (int i = 0; i < x; i++) {
                for (int p = 0; p < y; p++) {
                    if (i == 0 || p == 0 || (i == x - 1) || (p == y - 1)) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    } main {
        scan = new Scanner(System.in);

        while (true) {
            int x = scan.nextInt();
            int y = scan.nextInt();
            if (x == 0 && y == 0) {
                return;
            }
            for (int i = 0; i < x; i++) {
                for (int p = 0; p < y; p++) {
                    if (i == 0 || p == 0 || (i == x - 1) || (p == y - 1)) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    } scan = new Scanner(System.in) scan new Scanner(System.in) while (true) {
            int x = scan.nextInt();
            int y = scan.nextInt();
            if (x == 0 && y == 0) {
                return;
            }
            for (int i = 0; i < x; i++) {
                for (int p = 0; p < y; p++) {
                    if (i == 0 || p == 0 || (i == x - 1) || (p == y - 1)) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        } true {
            int x = scan.nextInt();
            int y = scan.nextInt();
            if (x == 0 && y == 0) {
                return;
            }
            for (int i = 0; i < x; i++) {
                for (int p = 0; p < y; p++) {
                    if (i == 0 || p == 0 || (i == x - 1) || (p == y - 1)) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        } int x = scan.nextInt(); x scan.nextInt() scan.nextInt scan int y = scan.nextInt(); y scan.nextInt() scan.nextInt scan if (x == 0 && y == 0) {
                return;
            } x == 0 && y == 0 x == 0 x 0 y == 0 y 0 {
                return;
            } return; for (int i = 0; i < x; i++) {
                for (int p = 0; p < y; p++) {
                    if (i == 0 || p == 0 || (i == x - 1) || (p == y - 1)) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.print("\n");
            } int i = 0; int i = 0; i 0 i < x i x i++ i++ i {
                for (int p = 0; p < y; p++) {
                    if (i == 0 || p == 0 || (i == x - 1) || (p == y - 1)) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.print("\n");
            } {
                for (int p = 0; p < y; p++) {
                    if (i == 0 || p == 0 || (i == x - 1) || (p == y - 1)) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.print("\n");
            } for (int p = 0; p < y; p++) {
                    if (i == 0 || p == 0 || (i == x - 1) || (p == y - 1)) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                } int p = 0; int p = 0; p 0 p < y p y p++ p++ p {
                    if (i == 0 || p == 0 || (i == x - 1) || (p == y - 1)) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                } {
                    if (i == 0 || p == 0 || (i == x - 1) || (p == y - 1)) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                } if (i == 0 || p == 0 || (i == x - 1) || (p == y - 1)) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    } i == 0 || p == 0 || (i == x - 1) || (p == y - 1) (i == x - 1) i == 0 || p == 0 || (i == x - 1) || (p == y - 1) i == 0 i 0 p == 0 p 0 (i == x - 1) i x - 1 x 1 (p == y - 1) p y - 1 y 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 "." System.out.print("\n") System.out.print System.out System System.out "\n" System.out.print("\n") System.out.print System.out System System.out "\n" String[] args args public class Main {
    private static Scanner scan;

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

        while (true) {
            int x = scan.nextInt();
            int y = scan.nextInt();
            if (x == 0 && y == 0) {
                return;
            }
            for (int i = 0; i < x; i++) {
                for (int p = 0; p < y; p++) {
                    if (i == 0 || p == 0 || (i == x - 1) || (p == y - 1)) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
} public class Main {
    private static Scanner scan;

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

        while (true) {
            int x = scan.nextInt();
            int y = scan.nextInt();
            if (x == 0 && y == 0) {
                return;
            }
            for (int i = 0; i < x; i++) {
                for (int p = 0; p < y; p++) {
                    if (i == 0 || p == 0 || (i == x - 1) || (p == y - 1)) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
} Main
import java.util.Scanner;

public class Main {
    private static Scanner scan;

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

        while (true) {
            int x = scan.nextInt();
            int y = scan.nextInt();
            if (x == 0 && y == 0) {
                return;
            }
            for (int i = 0; i < x; i++) {
                for (int p = 0; p < y; p++) {
                    if (i == 0 || p == 0 || (i == x - 1) || (p == y - 1)) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
}