import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.conv, std.stdio, std.typecons;

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

    if (h == 0 && w == 0) break;

    foreach (i; 0..h) {
      foreach (j; 0..w)
        write(i == 0 || i == h - 1 || j == 0 || j == w - 1 ? '#' : '.');
      writeln;
    }

    writeln;
  }
}