import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h == 0 && w == 0) break;
            solve(h, w);
            System.out.println("");
        }
    }
    
    private static void solve(int h, int w) {
        for (int i = 0;i < h;i++) {
            System.out.println(line(i, h, w));
        }
    }
    
    private static String line(int idx, int h, int w) {
        StringBuilder sb = new StringBuilder();
        if (idx == 0 || idx == h-1) {
            for (int i = 0;i < w;i++) sb.append("#");
        } else {
            sb.append("#");
            for (int i = 0;i < w-2;i++) sb.append(".");
            sb.append("#");
        }
        return sb.toString();
    }
} import java.util.*; util.* java public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h == 0 && w == 0) break;
            solve(h, w);
            System.out.println("");
        }
    }
    
    private static void solve(int h, int w) {
        for (int i = 0;i < h;i++) {
            System.out.println(line(i, h, w));
        }
    }
    
    private static String line(int idx, int h, int w) {
        StringBuilder sb = new StringBuilder();
        if (idx == 0 || idx == h-1) {
            for (int i = 0;i < w;i++) sb.append("#");
        } else {
            sb.append("#");
            for (int i = 0;i < w-2;i++) sb.append(".");
            sb.append("#");
        }
        return sb.toString();
    }
} Main private static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) throws Exception {
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h == 0 && w == 0) break;
            solve(h, w);
            System.out.println("");
        }
    } main {
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h == 0 && w == 0) break;
            solve(h, w);
            System.out.println("");
        }
    } while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h == 0 && w == 0) break;
            solve(h, w);
            System.out.println("");
        } true {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h == 0 && w == 0) break;
            solve(h, w);
            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; solve(h, w) solve h w System.out.println("") System.out.println System.out System System.out "" String[] args args private static void solve(int h, int w) {
        for (int i = 0;i < h;i++) {
            System.out.println(line(i, h, w));
        }
    } solve {
        for (int i = 0;i < h;i++) {
            System.out.println(line(i, h, w));
        }
    } for (int i = 0;i < h;i++) {
            System.out.println(line(i, h, w));
        } int i = 0; int i = 0; i 0 i < h i h i++ i++ i {
            System.out.println(line(i, h, w));
        } {
            System.out.println(line(i, h, w));
        } System.out.println(line(i, h, w)) System.out.println System.out System System.out line(i, h, w) line i h w int h h int w w private static String line(int idx, int h, int w) {
        StringBuilder sb = new StringBuilder();
        if (idx == 0 || idx == h-1) {
            for (int i = 0;i < w;i++) sb.append("#");
        } else {
            sb.append("#");
            for (int i = 0;i < w-2;i++) sb.append(".");
            sb.append("#");
        }
        return sb.toString();
    } line {
        StringBuilder sb = new StringBuilder();
        if (idx == 0 || idx == h-1) {
            for (int i = 0;i < w;i++) sb.append("#");
        } else {
            sb.append("#");
            for (int i = 0;i < w-2;i++) sb.append(".");
            sb.append("#");
        }
        return sb.toString();
    } StringBuilder sb = new StringBuilder(); sb new StringBuilder() if (idx == 0 || idx == h-1) {
            for (int i = 0;i < w;i++) sb.append("#");
        } else {
            sb.append("#");
            for (int i = 0;i < w-2;i++) sb.append(".");
            sb.append("#");
        } idx == 0 || idx == h-1 idx == 0 idx 0 idx == h-1 idx h-1 h 1 {
            for (int i = 0;i < w;i++) sb.append("#");
        } for (int i = 0;i < w;i++) sb.append("#"); int i = 0; int i = 0; i 0 i < w i w i++ i++ i sb.append("#"); sb.append("#") sb.append sb "#" {
            sb.append("#");
            for (int i = 0;i < w-2;i++) sb.append(".");
            sb.append("#");
        } sb.append("#") sb.append sb "#" for (int i = 0;i < w-2;i++) sb.append("."); int i = 0; int i = 0; i 0 i < w-2 i w-2 w 2 i++ i++ i sb.append("."); sb.append(".") sb.append sb "." sb.append("#") sb.append sb "#" return sb.toString(); sb.toString() sb.toString sb int idx idx int h h int w w public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h == 0 && w == 0) break;
            solve(h, w);
            System.out.println("");
        }
    }
    
    private static void solve(int h, int w) {
        for (int i = 0;i < h;i++) {
            System.out.println(line(i, h, w));
        }
    }
    
    private static String line(int idx, int h, int w) {
        StringBuilder sb = new StringBuilder();
        if (idx == 0 || idx == h-1) {
            for (int i = 0;i < w;i++) sb.append("#");
        } else {
            sb.append("#");
            for (int i = 0;i < w-2;i++) sb.append(".");
            sb.append("#");
        }
        return sb.toString();
    }
} public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h == 0 && w == 0) break;
            solve(h, w);
            System.out.println("");
        }
    }
    
    private static void solve(int h, int w) {
        for (int i = 0;i < h;i++) {
            System.out.println(line(i, h, w));
        }
    }
    
    private static String line(int idx, int h, int w) {
        StringBuilder sb = new StringBuilder();
        if (idx == 0 || idx == h-1) {
            for (int i = 0;i < w;i++) sb.append("#");
        } else {
            sb.append("#");
            for (int i = 0;i < w-2;i++) sb.append(".");
            sb.append("#");
        }
        return sb.toString();
    }
} Main
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h == 0 && w == 0) break;
            solve(h, w);
            System.out.println("");
        }
    }
    
    private static void solve(int h, int w) {
        for (int i = 0;i < h;i++) {
            System.out.println(line(i, h, w));
        }
    }
    
    private static String line(int idx, int h, int w) {
        StringBuilder sb = new StringBuilder();
        if (idx == 0 || idx == h-1) {
            for (int i = 0;i < w;i++) sb.append("#");
        } else {
            sb.append("#");
            for (int i = 0;i < w-2;i++) sb.append(".");
            sb.append("#");
        }
        return sb.toString();
    }
}