#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w;
  while (cin >> h >> w) {
    if (h == 0 && w == 0) {
      break;
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (i == 0 || i == h - 1) {
          cout << "#";
          if (j == w - 1) {
            cout << endl;
          }
        } else if (j == 0) {
          cout << "#";
        } else if (j == w - 1) {
          cout << "#" << endl;
        } else {
          cout << ".";
        }
      }
    }
    cout << endl;
  }
  return 0;
}
