const arr = require('fs').readFileSync('/dev/stdin','utf8').match(/^[\s\S]*?(?=\n0 0)/g)[0].split('\n').map(r=>r.split(' ').map(Number));
console.log(arr.map(([H,W])=>'#'.repeat(W).concat('\n').repeat(H)).join('\n').replace(/(?<!(\n\n|^)#+)(?<=#)#(?!#+\n(\n|$))(?!\n)/g,'.'))
