"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});
/* 入力は 
 */

var re = /\s+|$/;
reader.on('close', () => {
    for (var line of lines) {
	var l = line.trim().split(re).map(Number);
	var h,w;
	h=l[0];
	w=l[1];
	//console.log('h: ', h, 'w: ', w);
	if (h==0 && w==0) {
	    break;
	}
	console.log(aux(h,w));
    }
});

function aux(h,w)
{
    var l0='';
    var l1='';
    var s='';
    var o=''; 
    for (var i=0; i<w; i++) {
	o += '.';
    }

    l0 = o.replace(/./g, '#')    // '#####'
    l0 += '\n';
    l1 = o.replace(/^.|.$/g, '#')// '#.....#'
    l1 += '\n';
    
    for (var j=0; j<h; j++) {
	if (j==0 || j==h-1) {
	    s += l0;
	} else {
	    s += l1;
	}
    }
    //console.log('s: ', s)

    return(s);
}
