import java.util.Scanner;

public class Main {

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

    private static void solve(Scanner in) {
        while (true) {
            int H = in.nextInt();
            int W = in.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int i = 0; i < H; i++) {
                System.out.print("#");
                for (int j = 1; j < W - 1; j++) {
                    System.out.print(i == 0 || i == H - 1 ? "#" : ".");
                }
                System.out.print("#\n");
            }
            System.out.print("\n");
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {

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

    private static void solve(Scanner in) {
        while (true) {
            int H = in.nextInt();
            int W = in.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int i = 0; i < H; i++) {
                System.out.print("#");
                for (int j = 1; j < W - 1; j++) {
                    System.out.print(i == 0 || i == H - 1 ? "#" : ".");
                }
                System.out.print("#\n");
            }
            System.out.print("\n");
        }
    }
} Main public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    } main {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    } try (Scanner in = new Scanner(System.in)) {
            solve(in);
        } {
            solve(in);
        } Scanner in = new Scanner(System.in) Scanner in = new Scanner(System.in) new Scanner(System.in) solve(in) solve in String[] args args private static void solve(Scanner in) {
        while (true) {
            int H = in.nextInt();
            int W = in.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int i = 0; i < H; i++) {
                System.out.print("#");
                for (int j = 1; j < W - 1; j++) {
                    System.out.print(i == 0 || i == H - 1 ? "#" : ".");
                }
                System.out.print("#\n");
            }
            System.out.print("\n");
        }
    } solve {
        while (true) {
            int H = in.nextInt();
            int W = in.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int i = 0; i < H; i++) {
                System.out.print("#");
                for (int j = 1; j < W - 1; j++) {
                    System.out.print(i == 0 || i == H - 1 ? "#" : ".");
                }
                System.out.print("#\n");
            }
            System.out.print("\n");
        }
    } while (true) {
            int H = in.nextInt();
            int W = in.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int i = 0; i < H; i++) {
                System.out.print("#");
                for (int j = 1; j < W - 1; j++) {
                    System.out.print(i == 0 || i == H - 1 ? "#" : ".");
                }
                System.out.print("#\n");
            }
            System.out.print("\n");
        } true {
            int H = in.nextInt();
            int W = in.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int i = 0; i < H; i++) {
                System.out.print("#");
                for (int j = 1; j < W - 1; j++) {
                    System.out.print(i == 0 || i == H - 1 ? "#" : ".");
                }
                System.out.print("#\n");
            }
            System.out.print("\n");
        } int H = in.nextInt(); H in.nextInt() in.nextInt in int W = in.nextInt(); W in.nextInt() in.nextInt in if (H == 0 && W == 0) {
                break;
            } H == 0 && W == 0 H == 0 H 0 W == 0 W 0 {
                break;
            } break; for (int i = 0; i < H; i++) {
                System.out.print("#");
                for (int j = 1; j < W - 1; j++) {
                    System.out.print(i == 0 || i == H - 1 ? "#" : ".");
                }
                System.out.print("#\n");
            } int i = 0; int i = 0; i 0 i < H i H i++ i++ i {
                System.out.print("#");
                for (int j = 1; j < W - 1; j++) {
                    System.out.print(i == 0 || i == H - 1 ? "#" : ".");
                }
                System.out.print("#\n");
            } {
                System.out.print("#");
                for (int j = 1; j < W - 1; j++) {
                    System.out.print(i == 0 || i == H - 1 ? "#" : ".");
                }
                System.out.print("#\n");
            } System.out.print("#") System.out.print System.out System System.out "#" for (int j = 1; j < W - 1; j++) {
                    System.out.print(i == 0 || i == H - 1 ? "#" : ".");
                } int j = 1; int j = 1; j 1 j < W - 1 j W - 1 W 1 j++ j++ j {
                    System.out.print(i == 0 || i == H - 1 ? "#" : ".");
                } {
                    System.out.print(i == 0 || i == H - 1 ? "#" : ".");
                } System.out.print(i == 0 || i == H - 1 ? "#" : ".") System.out.print System.out System System.out i == 0 || i == H - 1 ? "#" : "." i == 0 || i == H - 1 i == 0 i 0 i == H - 1 i H - 1 H 1 "#" "." 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" Scanner in in public class Main {

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

    private static void solve(Scanner in) {
        while (true) {
            int H = in.nextInt();
            int W = in.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int i = 0; i < H; i++) {
                System.out.print("#");
                for (int j = 1; j < W - 1; j++) {
                    System.out.print(i == 0 || i == H - 1 ? "#" : ".");
                }
                System.out.print("#\n");
            }
            System.out.print("\n");
        }
    }
} public class Main {

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

    private static void solve(Scanner in) {
        while (true) {
            int H = in.nextInt();
            int W = in.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int i = 0; i < H; i++) {
                System.out.print("#");
                for (int j = 1; j < W - 1; j++) {
                    System.out.print(i == 0 || i == H - 1 ? "#" : ".");
                }
                System.out.print("#\n");
            }
            System.out.print("\n");
        }
    }
} Main
import java.util.Scanner;

public class Main {

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

    private static void solve(Scanner in) {
        while (true) {
            int H = in.nextInt();
            int W = in.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int i = 0; i < H; i++) {
                System.out.print("#");
                for (int j = 1; j < W - 1; j++) {
                    System.out.print(i == 0 || i == H - 1 ? "#" : ".");
                }
                System.out.print("#\n");
            }
            System.out.print("\n");
        }
    }
}