var std = process.stdin;
std.resume();
std.setEncoding('utf8');

std.on('data', function(chunk){
    var data = chunk.split(/\n/g);

    for (var i = 0; i < data.length; i++){
        var
            line = data[i].replace(/\n/, '').split(' ').map(Number),
            h = line[0],
            w = line[1];
        
        if(h === 0 && w === 0) {break;}
        draw(h, w);
        console.log();  //??????
    }
});

var draw = function(h, w) {
    for (var i = 0; i < h; i++) {
        var line = '';
        for (var j = 0; j < w; j++) {
            if (i === 0 || i + 1 === h
             || j === 0 || j + 1 === w) {
                line += '#';
            }
            else {
                line += '.';
            }
                
        }
        console.log(line);
    }  
};