'use strict';
(function(stdin) {
	var line  = stdin.toString();
	var result = (function(data) {
		return data
			.map(function(v) {
				return createTable(v[0],v[1]);
			}).join('\n');

		function createTable(rownum,colnum) {
			var table = [];
			for (var row = 0; row < rownum; row++) {
					(row === 0 || row === rownum -1) 
						? table.push(createLine(colnum,'#'))
						: table.push(createLine(colnum,'.'))
						;
			}
			table.push('');
			return table.join('\n');
		}

		function createLine(colnum,ch) {
			var line = '#';
			for (var col = 0; col < colnum -2 ; col++)
				line += ch;
			return line.concat('#');
		}

	}(
		line.split('\n0 0')[0]
		.split('\n')
		.map(function(v) {return v.split(' ').map(Number);})
	));
	console.log(result);

}(require('fs').readFileSync('/dev/stdin', 'utf8')));