import java.util.*;

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

        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();

            if (H == 0 && W == 0)
                break;

            p('#', W);
            pln();
            for (int n = H - 2; n > 0; n--) {
                p('#');
                p('.', W - 2);
                p('#');
                pln();
            }
            p('#', W);
            pln();
            pln();
        }
    }
    private static void p(char c, int n) {
        while (n-- > 0)
            System.out.print(c);
    }
    private static void p(char c) {
        p(c, 1);
    }
    private static void pln() {
        System.out.println();
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();

            if (H == 0 && W == 0)
                break;

            p('#', W);
            pln();
            for (int n = H - 2; n > 0; n--) {
                p('#');
                p('.', W - 2);
                p('#');
                pln();
            }
            p('#', W);
            pln();
            pln();
        }
    }
    private static void p(char c, int n) {
        while (n-- > 0)
            System.out.print(c);
    }
    private static void p(char c) {
        p(c, 1);
    }
    private static void pln() {
        System.out.println();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();

            if (H == 0 && W == 0)
                break;

            p('#', W);
            pln();
            for (int n = H - 2; n > 0; n--) {
                p('#');
                p('.', W - 2);
                p('#');
                pln();
            }
            p('#', W);
            pln();
            pln();
        }
    } main {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();

            if (H == 0 && W == 0)
                break;

            p('#', W);
            pln();
            for (int n = H - 2; n > 0; n--) {
                p('#');
                p('.', W - 2);
                p('#');
                pln();
            }
            p('#', W);
            pln();
            pln();
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();

            if (H == 0 && W == 0)
                break;

            p('#', W);
            pln();
            for (int n = H - 2; n > 0; n--) {
                p('#');
                p('.', W - 2);
                p('#');
                pln();
            }
            p('#', W);
            pln();
            pln();
        } true {
            int H = sc.nextInt();
            int W = sc.nextInt();

            if (H == 0 && W == 0)
                break;

            p('#', W);
            pln();
            for (int n = H - 2; n > 0; n--) {
                p('#');
                p('.', W - 2);
                p('#');
                pln();
            }
            p('#', W);
            pln();
            pln();
        } int H = sc.nextInt(); H sc.nextInt() sc.nextInt sc int W = sc.nextInt(); W sc.nextInt() sc.nextInt sc if (H == 0 && W == 0)
                break; H == 0 && W == 0 H == 0 H 0 W == 0 W 0 break; p('#', W) p '#' W pln() pln for (int n = H - 2; n > 0; n--) {
                p('#');
                p('.', W - 2);
                p('#');
                pln();
            } int n = H - 2; int n = H - 2; n H - 2 H 2 n > 0 n 0 n-- n-- n {
                p('#');
                p('.', W - 2);
                p('#');
                pln();
            } {
                p('#');
                p('.', W - 2);
                p('#');
                pln();
            } p('#') p '#' p('.', W - 2) p '.' W - 2 W 2 p('#') p '#' pln() pln p('#', W) p '#' W pln() pln pln() pln String[] args args private static void p(char c, int n) {
        while (n-- > 0)
            System.out.print(c);
    } p {
        while (n-- > 0)
            System.out.print(c);
    } while (n-- > 0)
            System.out.print(c); n-- > 0 n-- n 0 System.out.print(c) System.out.print System.out System System.out c char c c int n n private static void p(char c) {
        p(c, 1);
    } p {
        p(c, 1);
    } p(c, 1) p c 1 char c c private static void pln() {
        System.out.println();
    } pln {
        System.out.println();
    } System.out.println() System.out.println System.out System System.out public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();

            if (H == 0 && W == 0)
                break;

            p('#', W);
            pln();
            for (int n = H - 2; n > 0; n--) {
                p('#');
                p('.', W - 2);
                p('#');
                pln();
            }
            p('#', W);
            pln();
            pln();
        }
    }
    private static void p(char c, int n) {
        while (n-- > 0)
            System.out.print(c);
    }
    private static void p(char c) {
        p(c, 1);
    }
    private static void pln() {
        System.out.println();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();

            if (H == 0 && W == 0)
                break;

            p('#', W);
            pln();
            for (int n = H - 2; n > 0; n--) {
                p('#');
                p('.', W - 2);
                p('#');
                pln();
            }
            p('#', W);
            pln();
            pln();
        }
    }
    private static void p(char c, int n) {
        while (n-- > 0)
            System.out.print(c);
    }
    private static void p(char c) {
        p(c, 1);
    }
    private static void pln() {
        System.out.println();
    }
} Main
import java.util.*;

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

        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();

            if (H == 0 && W == 0)
                break;

            p('#', W);
            pln();
            for (int n = H - 2; n > 0; n--) {
                p('#');
                p('.', W - 2);
                p('#');
                pln();
            }
            p('#', W);
            pln();
            pln();
        }
    }
    private static void p(char c, int n) {
        while (n-- > 0)
            System.out.print(c);
    }
    private static void p(char c) {
        p(c, 1);
    }
    private static void pln() {
        System.out.println();
    }
}
