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