function main(input){
    let lines=input.split("\n");
    let i=0;
    while(lines[i]!=="0 0"){
        console.log(board(lines[i]));
        console.log("");
        i++;
        
        
    }
    
}
function board(line){
    let nums = line.split(" ").map(item=>parseInt(item));
    let height = nums[0];
    let width = nums[1]
    let put ="";
    
    for(let i=0;i<height;i++){
        if(i===0||i===height-1){
            for(let j=0;j<width;j++){
                put+="#";
            }
        }else{
            for(let j=0;j<width;j++){
                if(j===0||j===width-1){
                    put+="#";
                }else{
                    put+=".";
                }
                
            }
        }
        
        if(i!==height-1){
            put+="\n";
        }
    }
    return put.trim();
    
}


main(require("fs").readFileSync("/dev/stdin","utf-8"));
