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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		StringTokenizer st=new StringTokenizer(br.readLine());
		int H=Integer.parseInt(st.nextToken());
		int W=Integer.parseInt(st.nextToken());

		while(H!=0 || W!=0) {

			int i=1;
			int j=0;

			while(j<H) {
				while(i<W) {
					if(j>0 && i>1 && j+1<H && i<W) {
						System.out.print(".");
					}else {
						System.out.print("#");
					}
					i++;
				}
				System.out.println("#");
				i=1;
				j++;
			}
			System.out.println("");
			StringTokenizer sa=new StringTokenizer(br.readLine());
			H=Integer.parseInt(sa.nextToken());
			W=Integer.parseInt(sa.nextToken());
		}
	}

}