Problem:
Print a Frame

Draw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.

##########
#........#
#........#
#........#
#........#
##########

Input

The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.

The input ends with two 0 (when both H and W are zero).

Output

For each dataset, print the frame made of '#' and '.'.

Print a blank line after each dataset.

Constraints

3 ≤ H ≤ 300

3 ≤ W ≤ 300

Sample Input

3 4
5 6
3 3
0 0

Sample Output

####
#..#
####

######
#....#
#....#
#....#
######

###
#.#
###

Solution in JavaScript (judge verdict: Wrong Answer)

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 - 2; 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;
}