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 PHP (judge verdict: Accepted)

<?php

while (true) {
    
    fscanf(STDIN, "%d %d", $height, $width);
    
    if ($height == 0 && $width == 0){
        break;
    }
    
    $rectangle = new Rectangle($height, $width);
    $rectangles[] = $rectangle->drawCheck();
}

echo implode(PHP_EOL, $rectangles),PHP_EOL;

class Rectangle {
    
    private $height;
    private $width;
    
    public function __construct($height, $width){
        $this->height = $height;
        $this->width = $width;
    }
    
    public function draw(){
        $rectangle = [];
        for($i = 0; $i < $this->height; $i++){
            $rectangle[] = str_repeat("#", $this->width);
        }
        return implode(PHP_EOL, $rectangle).PHP_EOL;
    }
    
    public function drawCheck(){
        $rectangle = [];
        for($i = 0; $i < $this->height; $i++){
            if($i == 0 || $i == $this->height -1 || $this->width <= 2){
                $rectangle[] = str_repeat("#", $this->width);
            }else{
                $rectangle[] = "#".str_repeat(".", $this->width - 2)."#";
            }
        }
        return implode(PHP_EOL, $rectangle).PHP_EOL;
    }
    
}