const drawFrame = function (h, w) {
    console.log(Array(w + 1).join('#') + '\n'
        + Array(h - 1).join('#' + Array(w - 1).join('.') + '#\n')
        + Array(w + 1).join('#') + '\n');
};
const isZero = function (a) {return 0 === a;};

const chunk = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = chunk.split('\n');

while (true) {
    var hw = lines.shift().split(' ').map(Number);
    if (hw.every(isZero)) {
        break;
    }
    drawFrame(hw[0], hw[1]);
}