import java.util.Scanner;

/**
 *
 * @author lenovo
 */
public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        while (true) {
            int h = scanner.nextInt();
            int w = scanner.nextInt();
            for (int j = 0; j < h; j++) {
                String s = "";
                for (int i = 0; i < w; i++) {
                    if (j == 0 || j == h - 1) {
                        s = s + "#";
                    } else if (i == 0 || i == w - 1) {
                        s = s + "#";
                    } else {
                        s = s + ".";

                    }

                }
                System.out.println(s);

            }
            if (h == 0 || w == 0) {
                break;
            }
            System.out.print("\n");

        }

    }

} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        while (true) {
            int h = scanner.nextInt();
            int w = scanner.nextInt();
            for (int j = 0; j < h; j++) {
                String s = "";
                for (int i = 0; i < w; i++) {
                    if (j == 0 || j == h - 1) {
                        s = s + "#";
                    } else if (i == 0 || i == w - 1) {
                        s = s + "#";
                    } else {
                        s = s + ".";

                    }

                }
                System.out.println(s);

            }
            if (h == 0 || w == 0) {
                break;
            }
            System.out.print("\n");

        }

    }

} Main public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        while (true) {
            int h = scanner.nextInt();
            int w = scanner.nextInt();
            for (int j = 0; j < h; j++) {
                String s = "";
                for (int i = 0; i < w; i++) {
                    if (j == 0 || j == h - 1) {
                        s = s + "#";
                    } else if (i == 0 || i == w - 1) {
                        s = s + "#";
                    } else {
                        s = s + ".";

                    }

                }
                System.out.println(s);

            }
            if (h == 0 || w == 0) {
                break;
            }
            System.out.print("\n");

        }

    } main {

        Scanner scanner = new Scanner(System.in);
        while (true) {
            int h = scanner.nextInt();
            int w = scanner.nextInt();
            for (int j = 0; j < h; j++) {
                String s = "";
                for (int i = 0; i < w; i++) {
                    if (j == 0 || j == h - 1) {
                        s = s + "#";
                    } else if (i == 0 || i == w - 1) {
                        s = s + "#";
                    } else {
                        s = s + ".";

                    }

                }
                System.out.println(s);

            }
            if (h == 0 || w == 0) {
                break;
            }
            System.out.print("\n");

        }

    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) while (true) {
            int h = scanner.nextInt();
            int w = scanner.nextInt();
            for (int j = 0; j < h; j++) {
                String s = "";
                for (int i = 0; i < w; i++) {
                    if (j == 0 || j == h - 1) {
                        s = s + "#";
                    } else if (i == 0 || i == w - 1) {
                        s = s + "#";
                    } else {
                        s = s + ".";

                    }

                }
                System.out.println(s);

            }
            if (h == 0 || w == 0) {
                break;
            }
            System.out.print("\n");

        } true {
            int h = scanner.nextInt();
            int w = scanner.nextInt();
            for (int j = 0; j < h; j++) {
                String s = "";
                for (int i = 0; i < w; i++) {
                    if (j == 0 || j == h - 1) {
                        s = s + "#";
                    } else if (i == 0 || i == w - 1) {
                        s = s + "#";
                    } else {
                        s = s + ".";

                    }

                }
                System.out.println(s);

            }
            if (h == 0 || w == 0) {
                break;
            }
            System.out.print("\n");

        } int h = scanner.nextInt(); h scanner.nextInt() scanner.nextInt scanner int w = scanner.nextInt(); w scanner.nextInt() scanner.nextInt scanner for (int j = 0; j < h; j++) {
                String s = "";
                for (int i = 0; i < w; i++) {
                    if (j == 0 || j == h - 1) {
                        s = s + "#";
                    } else if (i == 0 || i == w - 1) {
                        s = s + "#";
                    } else {
                        s = s + ".";

                    }

                }
                System.out.println(s);

            } int j = 0; int j = 0; j 0 j < h j h j++ j++ j {
                String s = "";
                for (int i = 0; i < w; i++) {
                    if (j == 0 || j == h - 1) {
                        s = s + "#";
                    } else if (i == 0 || i == w - 1) {
                        s = s + "#";
                    } else {
                        s = s + ".";

                    }

                }
                System.out.println(s);

            } {
                String s = "";
                for (int i = 0; i < w; i++) {
                    if (j == 0 || j == h - 1) {
                        s = s + "#";
                    } else if (i == 0 || i == w - 1) {
                        s = s + "#";
                    } else {
                        s = s + ".";

                    }

                }
                System.out.println(s);

            } String s = ""; s "" for (int i = 0; i < w; i++) {
                    if (j == 0 || j == h - 1) {
                        s = s + "#";
                    } else if (i == 0 || i == w - 1) {
                        s = s + "#";
                    } else {
                        s = s + ".";

                    }

                } int i = 0; int i = 0; i 0 i < w i w i++ i++ i {
                    if (j == 0 || j == h - 1) {
                        s = s + "#";
                    } else if (i == 0 || i == w - 1) {
                        s = s + "#";
                    } else {
                        s = s + ".";

                    }

                } {
                    if (j == 0 || j == h - 1) {
                        s = s + "#";
                    } else if (i == 0 || i == w - 1) {
                        s = s + "#";
                    } else {
                        s = s + ".";

                    }

                } if (j == 0 || j == h - 1) {
                        s = s + "#";
                    } else if (i == 0 || i == w - 1) {
                        s = s + "#";
                    } else {
                        s = s + ".";

                    } j == 0 || j == h - 1 j == 0 j 0 j == h - 1 j h - 1 h 1 {
                        s = s + "#";
                    } s = s + "#" s s + "#" s "#" if (i == 0 || i == w - 1) {
                        s = s + "#";
                    } else {
                        s = s + ".";

                    } i == 0 || i == w - 1 i == 0 i 0 i == w - 1 i w - 1 w 1 {
                        s = s + "#";
                    } s = s + "#" s s + "#" s "#" {
                        s = s + ".";

                    } s = s + "." s s + "." s "." System.out.println(s) System.out.println System.out System System.out s if (h == 0 || w == 0) {
                break;
            } h == 0 || w == 0 h == 0 h 0 w == 0 w 0 {
                break;
            } break; System.out.print("\n") System.out.print System.out System System.out "\n" String[] args args public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        while (true) {
            int h = scanner.nextInt();
            int w = scanner.nextInt();
            for (int j = 0; j < h; j++) {
                String s = "";
                for (int i = 0; i < w; i++) {
                    if (j == 0 || j == h - 1) {
                        s = s + "#";
                    } else if (i == 0 || i == w - 1) {
                        s = s + "#";
                    } else {
                        s = s + ".";

                    }

                }
                System.out.println(s);

            }
            if (h == 0 || w == 0) {
                break;
            }
            System.out.print("\n");

        }

    }

} public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        while (true) {
            int h = scanner.nextInt();
            int w = scanner.nextInt();
            for (int j = 0; j < h; j++) {
                String s = "";
                for (int i = 0; i < w; i++) {
                    if (j == 0 || j == h - 1) {
                        s = s + "#";
                    } else if (i == 0 || i == w - 1) {
                        s = s + "#";
                    } else {
                        s = s + ".";

                    }

                }
                System.out.println(s);

            }
            if (h == 0 || w == 0) {
                break;
            }
            System.out.print("\n");

        }

    }

} Main
import java.util.Scanner;

/**
 *
 * @author lenovo
 */
public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        while (true) {
            int h = scanner.nextInt();
            int w = scanner.nextInt();
            for (int j = 0; j < h; j++) {
                String s = "";
                for (int i = 0; i < w; i++) {
                    if (j == 0 || j == h - 1) {
                        s = s + "#";
                    } else if (i == 0 || i == w - 1) {
                        s = s + "#";
                    } else {
                        s = s + ".";

                    }

                }
                System.out.println(s);

            }
            if (h == 0 || w == 0) {
                break;
            }
            System.out.print("\n");

        }

    }

}