const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const arr = input.split(/\n/);
let stack = "";
arr.forEach(item => {
  const rectangle = item.split(" ").map(Number);
  const h = rectangle[0];
  const w = rectangle[1];
  if(h === 0 && w === 0) return;
  for(let i = 0; i < h; i++) {
    let row = "";
    for(let j = 0; j < w; j++) {
      if(i === 0 || i === h - 1) {
        row += '#'
      } else {
        if (j === 0 || j === w - 1) {
          row += '#';
        } else {
          row += ".";
        }
      }
    }
    stack += row + "\n";
  }
  stack += "\n";
})
console.log(stack.trim() + "\n");
