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

void main() {
    auto input = getStdin!(string[]);
    foreach (line; input) {
    	auto num = line.split(" ").to!(int[]);
    	int width = num[1];
    	int height = num[0];
    	if (width == 0 && height == 0) break;

    	for (int i_h = 0; i_h < height; i_h++) {
    		for (int j_w = 0; j_w < width; j_w++) {
    			if (i_h == 0 || i_h == height - 1) {
    				"#".write;
    			}
    			else {
    				if (j_w == 0 || j_w == width - 1) {
    					"#".write;
    				}
    				else {
    					".".write;
    				}
    			}
    			
    			if (j_w == width - 1) {
    				"".writeln;
    			}
    		}
    	}
    	
    	"".writeln;
    }
}

T getStdin(T)() {
    string[] cmd;
    string line;
    while ((line = chomp(stdin.readln())) != "") cmd ~= line;
    return to!(T)(cmd);
}