#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int main() {
  int H, W;
  while (1) {
    cin >> H >> W;
    if (H == 0 && W == 0) break;
    for (int i = 0; i < (int)(H); i++) {
      for (int j = 0; j < (int)(W); j++) {
        if ((i == 0 || i == H - 1) && ((j != 0 && j != W - 1)))
          cout << ".";
        else
          cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
}
