#include <iostream>
using namespace std;

int main() {

	int h, w;
	while (cin >> h >> w && h || w) {
		for (int i = 1; i <= h; i++) {
			for (int k = 1; k <= w; k++) {
				if (i == 1 || k == 1 || i == h || k == w) {
					cout << '#';
				}else{
					cout << '.';
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}
