import java.util.*;

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

        while (true) {
            int H = scan.nextInt(), W = scan.nextInt();
            if (H == 0 && W == 0) {
                break;
            }

            for (int h = 0; h < H; h++) {
                if (h == 0 || h == H - 1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print("#");
                    }
                } else {
                    System.out.print("#");
                    for (int i = 0; i < W - 2; i++) {
                        System.out.print(".");
                    }
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        while (true) {
            int H = scan.nextInt(), W = scan.nextInt();
            if (H == 0 && W == 0) {
                break;
            }

            for (int h = 0; h < H; h++) {
                if (h == 0 || h == H - 1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print("#");
                    }
                } else {
                    System.out.print("#");
                    for (int i = 0; i < W - 2; i++) {
                        System.out.print(".");
                    }
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        while (true) {
            int H = scan.nextInt(), W = scan.nextInt();
            if (H == 0 && W == 0) {
                break;
            }

            for (int h = 0; h < H; h++) {
                if (h == 0 || h == H - 1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print("#");
                    }
                } else {
                    System.out.print("#");
                    for (int i = 0; i < W - 2; i++) {
                        System.out.print(".");
                    }
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    } main {
        Scanner scan = new Scanner(System.in);

        while (true) {
            int H = scan.nextInt(), W = scan.nextInt();
            if (H == 0 && W == 0) {
                break;
            }

            for (int h = 0; h < H; h++) {
                if (h == 0 || h == H - 1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print("#");
                    }
                } else {
                    System.out.print("#");
                    for (int i = 0; i < W - 2; i++) {
                        System.out.print(".");
                    }
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while (true) {
            int H = scan.nextInt(), W = scan.nextInt();
            if (H == 0 && W == 0) {
                break;
            }

            for (int h = 0; h < H; h++) {
                if (h == 0 || h == H - 1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print("#");
                    }
                } else {
                    System.out.print("#");
                    for (int i = 0; i < W - 2; i++) {
                        System.out.print(".");
                    }
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        } true {
            int H = scan.nextInt(), W = scan.nextInt();
            if (H == 0 && W == 0) {
                break;
            }

            for (int h = 0; h < H; h++) {
                if (h == 0 || h == H - 1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print("#");
                    }
                } else {
                    System.out.print("#");
                    for (int i = 0; i < W - 2; i++) {
                        System.out.print(".");
                    }
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        } int H = scan.nextInt() H scan.nextInt() scan.nextInt scan W = scan.nextInt(); W scan.nextInt() scan.nextInt scan if (H == 0 && W == 0) {
                break;
            } H == 0 && W == 0 H == 0 H 0 W == 0 W 0 {
                break;
            } break; for (int h = 0; h < H; h++) {
                if (h == 0 || h == H - 1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print("#");
                    }
                } else {
                    System.out.print("#");
                    for (int i = 0; i < W - 2; i++) {
                        System.out.print(".");
                    }
                    System.out.print("#");
                }
                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 {
                    System.out.print("#");
                    for (int i = 0; i < W - 2; i++) {
                        System.out.print(".");
                    }
                    System.out.print("#");
                }
                System.out.println();
            } {
                if (h == 0 || h == H - 1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print("#");
                    }
                } else {
                    System.out.print("#");
                    for (int i = 0; i < W - 2; i++) {
                        System.out.print(".");
                    }
                    System.out.print("#");
                }
                System.out.println();
            } if (h == 0 || h == H - 1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print("#");
                    }
                } else {
                    System.out.print("#");
                    for (int i = 0; i < W - 2; i++) {
                        System.out.print(".");
                    }
                    System.out.print("#");
                } 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 "#" {
                    System.out.print("#");
                    for (int i = 0; i < W - 2; i++) {
                        System.out.print(".");
                    }
                    System.out.print("#");
                } System.out.print("#") System.out.print System.out System System.out "#" for (int i = 0; i < W - 2; i++) {
                        System.out.print(".");
                    } int i = 0; int i = 0; i 0 i < W - 2 i W - 2 W 2 i++ i++ i {
                        System.out.print(".");
                    } {
                        System.out.print(".");
                    } System.out.print(".") System.out.print System.out System System.out "." System.out.print("#") System.out.print System.out System System.out "#" 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 scan = new Scanner(System.in);

        while (true) {
            int H = scan.nextInt(), W = scan.nextInt();
            if (H == 0 && W == 0) {
                break;
            }

            for (int h = 0; h < H; h++) {
                if (h == 0 || h == H - 1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print("#");
                    }
                } else {
                    System.out.print("#");
                    for (int i = 0; i < W - 2; i++) {
                        System.out.print(".");
                    }
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        while (true) {
            int H = scan.nextInt(), W = scan.nextInt();
            if (H == 0 && W == 0) {
                break;
            }

            for (int h = 0; h < H; h++) {
                if (h == 0 || h == H - 1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print("#");
                    }
                } else {
                    System.out.print("#");
                    for (int i = 0; i < W - 2; i++) {
                        System.out.print(".");
                    }
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
} Main
import java.util.*;

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

        while (true) {
            int H = scan.nextInt(), W = scan.nextInt();
            if (H == 0 && W == 0) {
                break;
            }

            for (int h = 0; h < H; h++) {
                if (h == 0 || h == H - 1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print("#");
                    }
                } else {
                    System.out.print("#");
                    for (int i = 0; i < W - 2; i++) {
                        System.out.print(".");
                    }
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}