#include <iostream>
#include <string>
using namespace std;

int main() {
  int h, w;
  while (cin >> h >> w, h | w) {
    string a(w, '#');
    string b = '#' + string(w - 2, '.') + '#';
    cout << a << endl;
    for (int i = 0; i < h-2; i++) {
      cout << b << endl;
    }
    cout << a << endl;
    cout << endl;
  }
}
