const input = require('fs').readFileSync('/dev/stdin', 'UTF-8');

const printFrame = input => {
  const array = input.split('\n');

  for (let i = 0; i < array.length; i++) {
    const [h, w] = array[i].split(' ').map(Number);

    if (h === 0 && w === 0) {
      return false;
    }

    const topBottom = Array(w + 1).join('#') + '\n';
    const middle = '#' + Array(w - 1).join('.') + '#\n';

    console.log([topBottom, middle.repeat(h - 2), topBottom].join(''));
  }
};

printFrame(input);
