import std.stdio, std.string, std.array, std.conv;

void main() {
    while (true) {
        int[] tmp = readln.chomp.split.to!(int[]);
        int h = tmp[0], w = tmp[1];
        if (h == 0 && w == 0) break;
        foreach (i; 0 .. h) {
            foreach (j; 0 .. w) {
                write(i == 0 || i == h - 1 || j == 0 || j == w - 1 ? "#" : ".");
            }
            writeln;
        }
        writeln;
    }
}
