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

void main()
{
    string s;
    while( (s=readln.strip) != "0 0") {
        auto n = map!(to!int)(s.strip.split);
        int h = n[0], w = n[1];

        writeln(replicate("#",w));
        for(int i=1;i<h-1;i++) {
          write("#");
          write(replicate(".",w-2));
          writeln("#");
        }
       if(h>1)
         writeln(replicate("#",w));
       writeln();
    }
}