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

void main()
{
  while (1) {
    string[] input = split(readln());
    int h = to!(int)(input[0]);
    int w = to!(int)(input[1]);

    if (h == 0 && w == 0) break;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (j != 0 && i != 0 && i != h - 1 && j != w - 1) {
          write(".");
        } else {
          write("#");
        }
      }
      write("\n");
    }
    write("\n");
  }
}