var line, res, i, h, w, j, cover, body;

line = require('fs').readFileSync('/dev/stdin', 'ascii').split("\n");
line.length = line.lastIndexOf('0 0');
for (i in line) line[i] = line[i].split(' ').map(Number);

res = [];
for (i in line) {
	h = line[i][0];
	w = line[i][1];
	cover = repeat("#", w);
	body = "#" + repeat(".", w - 2) + "#";
	res.push(cover);
	for (j = h - 3; j >= 0; j--) res.push(body);
	res.push(cover);
	res.push("");
}

console.log(res.join("\n"));

function repeat(str, n) {
	var binary, res, powstr, i, len;
	binary = n.toString(2);
	len = binary.length;
	res = "";
	powstr = str;
	for (i = len - 1; i > 0; i--) {
		if (binary[i] === '1') res = res + powstr;
		powstr = powstr + powstr;
	}
	return res + powstr;
}