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

int main(void){
	int h, w;
	string str;
	while (cin >> h >> w, h!=0 || w != 0){
		for (int i = 0; i < h; i++){
			if (i == 0 || i ==  h-1) str = string(w, '#');
			else str = '#' + string(w-2, '.') + '#';
			cout << str << endl;
		}
		cout << endl;
	}
	return 0;
}