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

void main() {
  while (true) {
    string[] input = split(readln());
    int H = to!int(input[0]);
    int W = to!int(input[1]);

    if (H == 0 && W == 0) return;

    for (int i = 0; i < H; ++i) {
      for (int j= 0; j < W; ++j) {
        write(is_side(i, j, H, W) ? "#" : ".");
      }
      writeln("");
    }
    writeln("");
  }
}

bool is_side(int y, int x, int H, int W) {
  return (y == 0 || x == 0 || y == (H - 1) || x == (W - 1));
}