Problem:
Print a Frame

Draw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.

##########
#........#
#........#
#........#
#........#
##########

Input

The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.

The input ends with two 0 (when both H and W are zero).

Output

For each dataset, print the frame made of '#' and '.'.

Print a blank line after each dataset.

Constraints

3 ≤ H ≤ 300

3 ≤ W ≤ 300

Sample Input

3 4
5 6
3 3
0 0

Sample Output

####
#..#
####

######
#....#
#....#
#....#
######

###
#.#
###

Solution in JavaScript (judge verdict: Accepted)

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);