'use strict';
const x = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = x.split(/\n/);

for (let i = 0; i < lines.length ; i++) {
  const arr = lines[i].split(/\s/).map(Number);
  if ((arr[0]===0)&&(arr[1]===0)) break;

  for (let i = 0; i < arr[0]; i++){
    if ((i===0)||(i===arr[0]-1)){
      for (let j= 0; j < arr[1]; j++){
        process.stdout.write('#');
      }
      console.log();
    }
    else {
      process.stdout.write('#');
      for (let j=1; j < arr[1]-1; j++){
        process.stdout.write('.');
      }
      console.log('#');
    }
  }
    console.log();
}


