Problem:
Print a Rectangle

Draw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.

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 rectangle made of H × W '#'.

Print a blank line after each dataset.

Constraints

1 ≤ H ≤ 300

1 ≤ W ≤ 300

Sample Input

3 4
5 6
2 2
0 0

Sample Output

####
####
####

######
######
######
######
######

##
##

Solution in JavaScript (judge verdict: Accepted)

var fs, max, scale, max_log2, max_pow2, series;

fs = require('fs');

max = 300;

function log2(n) {
	return n.toString(2).length - 1;
}

max_log2 = Math.floor(log2(max));
max_pow2 = Math.pow(2, max_log2);

series = function(max_pow2) {
	var i, series = [];
	for (i = max_pow2; i >= 1; i /= 2) series.push(i);
	return series;
} (max_pow2);

scale = function(max) {
	var scale, i, str;
	scale = [];
	str = "#";
	for (i = 1; i < max; i *= 2) {
		scale.push(str);
		str = str + str;
	}
	return scale.reverse();
}(max);

function get_column(W) {
	var i, res, rest;
	res = "";
	rest = W;
	for (i in series) {
		if (rest >= series[i]) {
			rest -= series[i];
			res = res + scale[i];
		}
	}
	return res;
}

function repeat(str, n) {
	return get_column(n).replace(/#/g, str);
}

function main() {
	var line, i, hw, end_i;
	line = fs.readFileSync('/dev/stdin', 'ascii').split("\n");
	end = false;
	for (i in line) {
		hw = line[i].split(' ', 2).map(Number);
		if (hw[0] === 0 && hw[1] === 0) {
			end_i = Number(i);
			break;
		}
		line[i] = repeat(get_column(hw[1]) + "\n", hw[0]) + "\n";
	}
	line.length = end_i;
	console.log(line.join("").trim() + "\n");
}

main();