function main(input) {
  var temp = input.split('\n');
  for (var i=0; i < temp.length; i++) {
    var data = temp[i].split(' ').map(Number);
    var height = data[0];
    var width = data[1];
    if(height == 0 && width == 0)
      break;
    var Filledline = "";
    for (var k = 0; k<width; k++) {
      Filledline += '#'
    }
    var line = "";
    for (var l = 0; l<width; l++) {
      if(l == 0 || l == width-1)
        line += "#";
      else
        line += ".";
      
    }
    for (var j = 0; j < height; j++) {
      if(j == 0 || j == height-1)
        console.log(Filledline);
      else
        console.log(line);
    }
    console.log('');
  }
}

var x = require('fs').readFileSync('/dev/stdin', 'utf-8');
main(x);
