process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (chunk) {
    const n = chunk.toString();
    const r = n.split("\n");
    r.forEach(x => st(x));
});

function st(men){
    const r = men.split(" ").map(x=>Number(x));
    const hiku = r[1]-2;
    var naka = "";
    var moji = "";
    var hiki = r[0]-2;
    for(var i = 0; i<r[1]; i++){
        if(r[i] != 0 && r[i+1] != 0){
            moji += "#";
        }
    }
    if(moji!=""){
        console.log(`${moji}`);
    }
    for(var i = 0; i < hiki; i++){
        for(var d = 0; d<hiku; d++){
            naka += ".";
        }
        console.log(`#${naka}#`);
        var naka = "";
    }
    if(moji!=""){
        console.log(`${moji}`);
        console.log("");
    }
}


