#include <iostream>
#define PUT(ch) cout << ch;
#define NL PUT(endl)
#define PUTS(ch,cnt) for (int i = 0; i < cnt; i++) { PUT(ch) }
using namespace std;
int main() {
int h, w;
while (true) {
cin >> h >> w;
if (0 == (h | w)) {
break;
}
PUTS('#', w)
NL
for (int j = 2; j < h; j++) {
PUT('#')
PUTS('.', w - 2)
PUT('#')
NL
}
PUTS('#', w)
NL
NL
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojZGVmaW5lIFBVVChjaCkgY291dCA8PCBjaDsKI2RlZmluZSBOTCBQVVQoZW5kbCkKI2RlZmluZSBQVVRTKGNoLGNudCkgZm9yIChpbnQgaSA9IDA7IGkgPCBjbnQ7IGkrKykgeyBQVVQoY2gpIH0KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewoJaW50IGgsIHc7Cgl3aGlsZSAodHJ1ZSkgewoJCWNpbiA+PiBoID4+IHc7CgkJaWYgKDAgPT0gKGggfCB3KSkgewoJCQlicmVhazsKCQl9CgkJUFVUUygnIycsIHcpCgkJTkwKCQlmb3IgKGludCBqID0gMjsgaiA8IGg7IGorKykgewoJCQlQVVQoJyMnKQoJCQlQVVRTKCcuJywgdyAtIDIpCgkJCVBVVCgnIycpCgkJCU5MCgkJfQoJCVBVVFMoJyMnLCB3KQoJCU5MCgkJTkwKCX0KCXJldHVybiAwOwp9Cgo=