const input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
console.log(input.map(function(x) {
  const arr = x.split(' ').map(Number);
  return arr[0] == 0 ? '' : function(h, w) {
    const frame = [];
    const ends = Array(w+1).join('#').concat('\n');
    frame.push(ends);
    frame.push(Array(h - 1).join('#'.concat(Array(w - 1).join('.').concat('#\n'))));
    frame.push(ends);
    return frame.join('');
  }(arr[0], arr[1]);
}).join('\n').trim().concat('\n'));