// 'use strict';
(function(stdin) {
  //declare function
  function square(a) {
    var h = a[0];
    var w = a[1];
    var top = [];
    var midle = [];
    var result = [];
    for (var i = 0; i < w; i++) {
      top.push('#');
    }
    for (var j = 0; j < w - 2; j++) {
      midle.push('.');
    }
    midle.push('#');
    midle.unshift('#');
    for (var k = 0; k < h - 2; k++) {
      result.push(midle.join(''));
    }
    result.push(top.join(''));
    result.unshift(top.join(''));
    return result.join('\n');
  }

  //declare variable
  var inputs = stdin.toString().trim().split('\n');
  var numData = inputs.slice(0, inputs.indexOf('0 0'));
  var HAndW = numData.map(function(v) {
    return v.split(' ').map(Number);
  });
  //main

  //display
  console.log(HAndW.map(square).join('\n\n'));
})(require('fs').readFileSync('/dev/stdin', 'utf8'));