'use strict'

const main = arg => {
    const input = arg.trim().split("\n");
    const rectangle = [];
    input.some(str => {
        if(str === "0 0"){ return true; } //break;
        const num = str.split(" ");
        const height = parseInt(num[0], 10);
        const width = parseInt(num[1], 10);

        [...Array(height)].forEach((obj, h) => {
            var len = "";
            [...Array(width)].forEach((obj,w) => {
                if([0, height-1].includes(h)){
                    len += "#";
                } else {
                    len += [0, width-1].includes(w) ? "#" : ".";
                }
            });
            rectangle.push(len);
        });
        rectangle.push("");
    });

    console.log(rectangle.join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
