import java.util.*;
import java.text.*;

class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        for(;;) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h == 0 && w == 0) break;
            String s = "";
            String t = "";
            for(int i = 0; i < w; i++) {
                s += "#";
                t += (i == 0 || i == (w-1)) ? "#" : ".";
            }
            for(int i = 0; i < h; i++) {
                System.out.println((i == 0 || i == (h-1)) ? s : t);
            }
            System.out.println();
        }
    }
} import java.util.*; util.* java import java.text.*; text.* java class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        for(;;) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h == 0 && w == 0) break;
            String s = "";
            String t = "";
            for(int i = 0; i < w; i++) {
                s += "#";
                t += (i == 0 || i == (w-1)) ? "#" : ".";
            }
            for(int i = 0; i < h; i++) {
                System.out.println((i == 0 || i == (h-1)) ? s : t);
            }
            System.out.println();
        }
    }
} Main public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        for(;;) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h == 0 && w == 0) break;
            String s = "";
            String t = "";
            for(int i = 0; i < w; i++) {
                s += "#";
                t += (i == 0 || i == (w-1)) ? "#" : ".";
            }
            for(int i = 0; i < h; i++) {
                System.out.println((i == 0 || i == (h-1)) ? s : t);
            }
            System.out.println();
        }
    } main {
        Scanner sc = new Scanner(System.in);
        for(;;) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h == 0 && w == 0) break;
            String s = "";
            String t = "";
            for(int i = 0; i < w; i++) {
                s += "#";
                t += (i == 0 || i == (w-1)) ? "#" : ".";
            }
            for(int i = 0; i < h; i++) {
                System.out.println((i == 0 || i == (h-1)) ? s : t);
            }
            System.out.println();
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) for(;;) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h == 0 && w == 0) break;
            String s = "";
            String t = "";
            for(int i = 0; i < w; i++) {
                s += "#";
                t += (i == 0 || i == (w-1)) ? "#" : ".";
            }
            for(int i = 0; i < h; i++) {
                System.out.println((i == 0 || i == (h-1)) ? s : t);
            }
            System.out.println();
        } ; {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h == 0 && w == 0) break;
            String s = "";
            String t = "";
            for(int i = 0; i < w; i++) {
                s += "#";
                t += (i == 0 || i == (w-1)) ? "#" : ".";
            }
            for(int i = 0; i < h; i++) {
                System.out.println((i == 0 || i == (h-1)) ? s : t);
            }
            System.out.println();
        } {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h == 0 && w == 0) break;
            String s = "";
            String t = "";
            for(int i = 0; i < w; i++) {
                s += "#";
                t += (i == 0 || i == (w-1)) ? "#" : ".";
            }
            for(int i = 0; i < h; i++) {
                System.out.println((i == 0 || i == (h-1)) ? s : t);
            }
            System.out.println();
        } 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; String s = ""; s "" String t = ""; t "" for(int i = 0; i < w; i++) {
                s += "#";
                t += (i == 0 || i == (w-1)) ? "#" : ".";
            } int i = 0; int i = 0; i 0 i < w i w i++ i++ i {
                s += "#";
                t += (i == 0 || i == (w-1)) ? "#" : ".";
            } {
                s += "#";
                t += (i == 0 || i == (w-1)) ? "#" : ".";
            } s += "#" s "#" t += (i == 0 || i == (w-1)) ? "#" : "." t (i == 0 || i == (w-1)) ? "#" : "." (i == 0 || i == (w-1)) i == 0 i 0 i == (w-1) i (w-1) w 1 "#" "." for(int i = 0; i < h; i++) {
                System.out.println((i == 0 || i == (h-1)) ? s : t);
            } int i = 0; int i = 0; i 0 i < h i h i++ i++ i {
                System.out.println((i == 0 || i == (h-1)) ? s : t);
            } {
                System.out.println((i == 0 || i == (h-1)) ? s : t);
            } System.out.println((i == 0 || i == (h-1)) ? s : t) System.out.println System.out System System.out (i == 0 || i == (h-1)) ? s : t (i == 0 || i == (h-1)) i == 0 i 0 i == (h-1) i (h-1) h 1 s t System.out.println() System.out.println System.out System System.out String[]args args
import java.util.*;
import java.text.*;

class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        for(;;) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h == 0 && w == 0) break;
            String s = "";
            String t = "";
            for(int i = 0; i < w; i++) {
                s += "#";
                t += (i == 0 || i == (w-1)) ? "#" : ".";
            }
            for(int i = 0; i < h; i++) {
                System.out.println((i == 0 || i == (h-1)) ? s : t);
            }
            System.out.println();
        }
    }
}