import java.util.Scanner;

class Main {

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

        while (true) {
            int height = scan.nextInt();
            int width  = scan.nextInt();

            if (height == 0 && width == 0) {
                break;
            }

            for (int i = 0; i < width; i++) {
                System.out.print("#");
            }
            System.out.println();
            for (int i = 1; i < height - 1; i++) {
                System.out.print("#");
                for (int j = 1; j < width - 1; j++) {
                    System.out.print(".");
                }
                System.out.println("#");
            }
            for (int i = 0; i < width; i++) {
                System.out.print("#");
            }
            System.out.println("\n");
        }
    }

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

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

        while (true) {
            int height = scan.nextInt();
            int width  = scan.nextInt();

            if (height == 0 && width == 0) {
                break;
            }

            for (int i = 0; i < width; i++) {
                System.out.print("#");
            }
            System.out.println();
            for (int i = 1; i < height - 1; i++) {
                System.out.print("#");
                for (int j = 1; j < width - 1; j++) {
                    System.out.print(".");
                }
                System.out.println("#");
            }
            for (int i = 0; i < width; i++) {
                System.out.print("#");
            }
            System.out.println("\n");
        }
    }

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

        while (true) {
            int height = scan.nextInt();
            int width  = scan.nextInt();

            if (height == 0 && width == 0) {
                break;
            }

            for (int i = 0; i < width; i++) {
                System.out.print("#");
            }
            System.out.println();
            for (int i = 1; i < height - 1; i++) {
                System.out.print("#");
                for (int j = 1; j < width - 1; j++) {
                    System.out.print(".");
                }
                System.out.println("#");
            }
            for (int i = 0; i < width; i++) {
                System.out.print("#");
            }
            System.out.println("\n");
        }
    } main {
        Scanner scan = new Scanner(System.in);

        while (true) {
            int height = scan.nextInt();
            int width  = scan.nextInt();

            if (height == 0 && width == 0) {
                break;
            }

            for (int i = 0; i < width; i++) {
                System.out.print("#");
            }
            System.out.println();
            for (int i = 1; i < height - 1; i++) {
                System.out.print("#");
                for (int j = 1; j < width - 1; j++) {
                    System.out.print(".");
                }
                System.out.println("#");
            }
            for (int i = 0; i < width; i++) {
                System.out.print("#");
            }
            System.out.println("\n");
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while (true) {
            int height = scan.nextInt();
            int width  = scan.nextInt();

            if (height == 0 && width == 0) {
                break;
            }

            for (int i = 0; i < width; i++) {
                System.out.print("#");
            }
            System.out.println();
            for (int i = 1; i < height - 1; i++) {
                System.out.print("#");
                for (int j = 1; j < width - 1; j++) {
                    System.out.print(".");
                }
                System.out.println("#");
            }
            for (int i = 0; i < width; i++) {
                System.out.print("#");
            }
            System.out.println("\n");
        } true {
            int height = scan.nextInt();
            int width  = scan.nextInt();

            if (height == 0 && width == 0) {
                break;
            }

            for (int i = 0; i < width; i++) {
                System.out.print("#");
            }
            System.out.println();
            for (int i = 1; i < height - 1; i++) {
                System.out.print("#");
                for (int j = 1; j < width - 1; j++) {
                    System.out.print(".");
                }
                System.out.println("#");
            }
            for (int i = 0; i < width; i++) {
                System.out.print("#");
            }
            System.out.println("\n");
        } int height = scan.nextInt(); height scan.nextInt() scan.nextInt scan int width  = scan.nextInt(); width scan.nextInt() scan.nextInt scan if (height == 0 && width == 0) {
                break;
            } height == 0 && width == 0 height == 0 height 0 width == 0 width 0 {
                break;
            } break; for (int i = 0; i < width; i++) {
                System.out.print("#");
            } int i = 0; int i = 0; i 0 i < width i width i++ i++ i {
                System.out.print("#");
            } {
                System.out.print("#");
            } System.out.print("#") System.out.print System.out System System.out "#" System.out.println() System.out.println System.out System System.out for (int i = 1; i < height - 1; i++) {
                System.out.print("#");
                for (int j = 1; j < width - 1; j++) {
                    System.out.print(".");
                }
                System.out.println("#");
            } int i = 1; int i = 1; i 1 i < height - 1 i height - 1 height 1 i++ i++ i {
                System.out.print("#");
                for (int j = 1; j < width - 1; j++) {
                    System.out.print(".");
                }
                System.out.println("#");
            } {
                System.out.print("#");
                for (int j = 1; j < width - 1; j++) {
                    System.out.print(".");
                }
                System.out.println("#");
            } System.out.print("#") System.out.print System.out System System.out "#" for (int j = 1; j < width - 1; j++) {
                    System.out.print(".");
                } int j = 1; int j = 1; j 1 j < width - 1 j width - 1 width 1 j++ j++ j {
                    System.out.print(".");
                } {
                    System.out.print(".");
                } System.out.print(".") System.out.print System.out System System.out "." System.out.println("#") System.out.println System.out System System.out "#" for (int i = 0; i < width; i++) {
                System.out.print("#");
            } int i = 0; int i = 0; i 0 i < width i width i++ i++ i {
                System.out.print("#");
            } {
                System.out.print("#");
            } System.out.print("#") System.out.print System.out System System.out "#" System.out.println("\n") System.out.println System.out System System.out "\n" String[] args args
import java.util.Scanner;

class Main {

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

        while (true) {
            int height = scan.nextInt();
            int width  = scan.nextInt();

            if (height == 0 && width == 0) {
                break;
            }

            for (int i = 0; i < width; i++) {
                System.out.print("#");
            }
            System.out.println();
            for (int i = 1; i < height - 1; i++) {
                System.out.print("#");
                for (int j = 1; j < width - 1; j++) {
                    System.out.print(".");
                }
                System.out.println("#");
            }
            for (int i = 0; i < width; i++) {
                System.out.print("#");
            }
            System.out.println("\n");
        }
    }

}