import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int H;
        int W;
        while ((H = scanner.nextInt()) != 0 && (W = scanner.nextInt()) != 0) {
            for (int h = 0; h < H; h++) {
                if (h == 0 || h == H-1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print('#');
                    }
                } else {
                    for (int w = 0; w < W; w++) {
                        char c = '.';
                        if (w == 0 || w == W-1) c = '#';
                        System.out.print(c);
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int H;
        int W;
        while ((H = scanner.nextInt()) != 0 && (W = scanner.nextInt()) != 0) {
            for (int h = 0; h < H; h++) {
                if (h == 0 || h == H-1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print('#');
                    }
                } else {
                    for (int w = 0; w < W; w++) {
                        char c = '.';
                        if (w == 0 || w == W-1) c = '#';
                        System.out.print(c);
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int H;
        int W;
        while ((H = scanner.nextInt()) != 0 && (W = scanner.nextInt()) != 0) {
            for (int h = 0; h < H; h++) {
                if (h == 0 || h == H-1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print('#');
                    }
                } else {
                    for (int w = 0; w < W; w++) {
                        char c = '.';
                        if (w == 0 || w == W-1) c = '#';
                        System.out.print(c);
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    } main {
        Scanner scanner = new Scanner(System.in);
        int H;
        int W;
        while ((H = scanner.nextInt()) != 0 && (W = scanner.nextInt()) != 0) {
            for (int h = 0; h < H; h++) {
                if (h == 0 || h == H-1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print('#');
                    }
                } else {
                    for (int w = 0; w < W; w++) {
                        char c = '.';
                        if (w == 0 || w == W-1) c = '#';
                        System.out.print(c);
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int H; H int W; W while ((H = scanner.nextInt()) != 0 && (W = scanner.nextInt()) != 0) {
            for (int h = 0; h < H; h++) {
                if (h == 0 || h == H-1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print('#');
                    }
                } else {
                    for (int w = 0; w < W; w++) {
                        char c = '.';
                        if (w == 0 || w == W-1) c = '#';
                        System.out.print(c);
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        } (H = scanner.nextInt()) != 0 && (W = scanner.nextInt()) != 0 (H = scanner.nextInt()) != 0 (H = scanner.nextInt()) H scanner.nextInt() scanner.nextInt scanner 0 (W = scanner.nextInt()) != 0 (W = scanner.nextInt()) W scanner.nextInt() scanner.nextInt scanner 0 {
            for (int h = 0; h < H; h++) {
                if (h == 0 || h == H-1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print('#');
                    }
                } else {
                    for (int w = 0; w < W; w++) {
                        char c = '.';
                        if (w == 0 || w == W-1) c = '#';
                        System.out.print(c);
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        } for (int h = 0; h < H; h++) {
                if (h == 0 || h == H-1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print('#');
                    }
                } else {
                    for (int w = 0; w < W; w++) {
                        char c = '.';
                        if (w == 0 || w == W-1) c = '#';
                        System.out.print(c);
                    }
                }
                System.out.println("");
            } int h = 0; int h = 0; h 0 h < H h H h++ h++ h {
                if (h == 0 || h == H-1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print('#');
                    }
                } else {
                    for (int w = 0; w < W; w++) {
                        char c = '.';
                        if (w == 0 || w == W-1) c = '#';
                        System.out.print(c);
                    }
                }
                System.out.println("");
            } {
                if (h == 0 || h == H-1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print('#');
                    }
                } else {
                    for (int w = 0; w < W; w++) {
                        char c = '.';
                        if (w == 0 || w == W-1) c = '#';
                        System.out.print(c);
                    }
                }
                System.out.println("");
            } if (h == 0 || h == H-1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print('#');
                    }
                } else {
                    for (int w = 0; w < W; w++) {
                        char c = '.';
                        if (w == 0 || w == W-1) c = '#';
                        System.out.print(c);
                    }
                } h == 0 || h == H-1 h == 0 h 0 h == H-1 h H-1 H 1 {
                    for (int w = 0; w < W; w++) {
                        System.out.print('#');
                    }
                } for (int w = 0; w < W; w++) {
                        System.out.print('#');
                    } int w = 0; int w = 0; w 0 w < W w W w++ w++ w {
                        System.out.print('#');
                    } {
                        System.out.print('#');
                    } System.out.print('#') System.out.print System.out System System.out '#' {
                    for (int w = 0; w < W; w++) {
                        char c = '.';
                        if (w == 0 || w == W-1) c = '#';
                        System.out.print(c);
                    }
                } for (int w = 0; w < W; w++) {
                        char c = '.';
                        if (w == 0 || w == W-1) c = '#';
                        System.out.print(c);
                    } int w = 0; int w = 0; w 0 w < W w W w++ w++ w {
                        char c = '.';
                        if (w == 0 || w == W-1) c = '#';
                        System.out.print(c);
                    } {
                        char c = '.';
                        if (w == 0 || w == W-1) c = '#';
                        System.out.print(c);
                    } char c = '.'; c '.' if (w == 0 || w == W-1) c = '#'; w == 0 || w == W-1 w == 0 w 0 w == W-1 w W-1 W 1 c = '#' c '#' System.out.print(c) System.out.print System.out System System.out c System.out.println("") System.out.println System.out System System.out "" System.out.println("") System.out.println System.out System System.out "" String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int H;
        int W;
        while ((H = scanner.nextInt()) != 0 && (W = scanner.nextInt()) != 0) {
            for (int h = 0; h < H; h++) {
                if (h == 0 || h == H-1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print('#');
                    }
                } else {
                    for (int w = 0; w < W; w++) {
                        char c = '.';
                        if (w == 0 || w == W-1) c = '#';
                        System.out.print(c);
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int H;
        int W;
        while ((H = scanner.nextInt()) != 0 && (W = scanner.nextInt()) != 0) {
            for (int h = 0; h < H; h++) {
                if (h == 0 || h == H-1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print('#');
                    }
                } else {
                    for (int w = 0; w < W; w++) {
                        char c = '.';
                        if (w == 0 || w == W-1) c = '#';
                        System.out.print(c);
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int H;
        int W;
        while ((H = scanner.nextInt()) != 0 && (W = scanner.nextInt()) != 0) {
            for (int h = 0; h < H; h++) {
                if (h == 0 || h == H-1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print('#');
                    }
                } else {
                    for (int w = 0; w < W; w++) {
                        char c = '.';
                        if (w == 0 || w == W-1) c = '#';
                        System.out.print(c);
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
}
