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

void main() {
  while (true) {
    auto input = readln.chomp.split.map!(to!int);
    if (input.array == [0, 0]) break;
    int h = input[0];
    int w = input[1];

    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (i == 0 || i == h - 1) {
          write("#");
        } else {
          if (j == 0 || j == w - 1) {
            write("#");
          } else {
            write(".");
          }
        }
      }

      writeln;
    }

    writeln;
  }
}