
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc =new Scanner(System.in);
		String[] input;

		while(true){
			input=sc.nextLine().split(" ");
			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);
			if(H==0 && W==0){
				break;
			}
			for(int in1=0;in1<H;in1++){
				for(int in2 =0; in2<W; in2++){
					if(in1==0 || in1==H-1 || in2==0 || in2==W-1){
						System.out.print("#");
						if(in2==W-1){
							System.out.println();
						}
					}else{
						System.out.print(".");
					}
				}
			}
			System.out.println();
		}
	}
} import java.util.Scanner; Scanner java.util class Main{
	public static void main(String args[]){
		Scanner sc =new Scanner(System.in);
		String[] input;

		while(true){
			input=sc.nextLine().split(" ");
			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);
			if(H==0 && W==0){
				break;
			}
			for(int in1=0;in1<H;in1++){
				for(int in2 =0; in2<W; in2++){
					if(in1==0 || in1==H-1 || in2==0 || in2==W-1){
						System.out.print("#");
						if(in2==W-1){
							System.out.println();
						}
					}else{
						System.out.print(".");
					}
				}
			}
			System.out.println();
		}
	}
} Main public static void main(String args[]){
		Scanner sc =new Scanner(System.in);
		String[] input;

		while(true){
			input=sc.nextLine().split(" ");
			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);
			if(H==0 && W==0){
				break;
			}
			for(int in1=0;in1<H;in1++){
				for(int in2 =0; in2<W; in2++){
					if(in1==0 || in1==H-1 || in2==0 || in2==W-1){
						System.out.print("#");
						if(in2==W-1){
							System.out.println();
						}
					}else{
						System.out.print(".");
					}
				}
			}
			System.out.println();
		}
	} main {
		Scanner sc =new Scanner(System.in);
		String[] input;

		while(true){
			input=sc.nextLine().split(" ");
			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);
			if(H==0 && W==0){
				break;
			}
			for(int in1=0;in1<H;in1++){
				for(int in2 =0; in2<W; in2++){
					if(in1==0 || in1==H-1 || in2==0 || in2==W-1){
						System.out.print("#");
						if(in2==W-1){
							System.out.println();
						}
					}else{
						System.out.print(".");
					}
				}
			}
			System.out.println();
		}
	} Scanner sc =new Scanner(System.in); sc new Scanner(System.in) String[] input; input while(true){
			input=sc.nextLine().split(" ");
			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);
			if(H==0 && W==0){
				break;
			}
			for(int in1=0;in1<H;in1++){
				for(int in2 =0; in2<W; in2++){
					if(in1==0 || in1==H-1 || in2==0 || in2==W-1){
						System.out.print("#");
						if(in2==W-1){
							System.out.println();
						}
					}else{
						System.out.print(".");
					}
				}
			}
			System.out.println();
		} true {
			input=sc.nextLine().split(" ");
			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);
			if(H==0 && W==0){
				break;
			}
			for(int in1=0;in1<H;in1++){
				for(int in2 =0; in2<W; in2++){
					if(in1==0 || in1==H-1 || in2==0 || in2==W-1){
						System.out.print("#");
						if(in2==W-1){
							System.out.println();
						}
					}else{
						System.out.print(".");
					}
				}
			}
			System.out.println();
		} input=sc.nextLine().split(" ") input sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int H = Integer.parseInt(input[0]); H Integer.parseInt(input[0]) Integer.parseInt Integer input[0] input 0 int W = Integer.parseInt(input[1]); W Integer.parseInt(input[1]) Integer.parseInt Integer input[1] input 1 if(H==0 && W==0){
				break;
			} H==0 && W==0 H==0 H 0 W==0 W 0 {
				break;
			} break; for(int in1=0;in1<H;in1++){
				for(int in2 =0; in2<W; in2++){
					if(in1==0 || in1==H-1 || in2==0 || in2==W-1){
						System.out.print("#");
						if(in2==W-1){
							System.out.println();
						}
					}else{
						System.out.print(".");
					}
				}
			} int in1=0; int in1=0; in1 0 in1<H in1 H in1++ in1++ in1 {
				for(int in2 =0; in2<W; in2++){
					if(in1==0 || in1==H-1 || in2==0 || in2==W-1){
						System.out.print("#");
						if(in2==W-1){
							System.out.println();
						}
					}else{
						System.out.print(".");
					}
				}
			} {
				for(int in2 =0; in2<W; in2++){
					if(in1==0 || in1==H-1 || in2==0 || in2==W-1){
						System.out.print("#");
						if(in2==W-1){
							System.out.println();
						}
					}else{
						System.out.print(".");
					}
				}
			} for(int in2 =0; in2<W; in2++){
					if(in1==0 || in1==H-1 || in2==0 || in2==W-1){
						System.out.print("#");
						if(in2==W-1){
							System.out.println();
						}
					}else{
						System.out.print(".");
					}
				} int in2 =0; int in2 =0; in2 0 in2<W in2 W in2++ in2++ in2 {
					if(in1==0 || in1==H-1 || in2==0 || in2==W-1){
						System.out.print("#");
						if(in2==W-1){
							System.out.println();
						}
					}else{
						System.out.print(".");
					}
				} {
					if(in1==0 || in1==H-1 || in2==0 || in2==W-1){
						System.out.print("#");
						if(in2==W-1){
							System.out.println();
						}
					}else{
						System.out.print(".");
					}
				} if(in1==0 || in1==H-1 || in2==0 || in2==W-1){
						System.out.print("#");
						if(in2==W-1){
							System.out.println();
						}
					}else{
						System.out.print(".");
					} in1==0 || in1==H-1 || in2==0 || in2==W-1 in2==0 in1==0 || in1==H-1 || in2==0 || in2==W-1 in1==0 in1 0 in1==H-1 in1 H-1 H 1 in2==0 in2 0 in2==W-1 in2 W-1 W 1 {
						System.out.print("#");
						if(in2==W-1){
							System.out.println();
						}
					} System.out.print("#") System.out.print System.out System System.out "#" if(in2==W-1){
							System.out.println();
						} in2==W-1 in2 W-1 W 1 {
							System.out.println();
						} System.out.println() System.out.println System.out System System.out {
						System.out.print(".");
					} System.out.print(".") System.out.print System.out System System.out "." System.out.println() System.out.println System.out System System.out String args[] args

import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc =new Scanner(System.in);
		String[] input;

		while(true){
			input=sc.nextLine().split(" ");
			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);
			if(H==0 && W==0){
				break;
			}
			for(int in1=0;in1<H;in1++){
				for(int in2 =0; in2<W; in2++){
					if(in1==0 || in1==H-1 || in2==0 || in2==W-1){
						System.out.print("#");
						if(in2==W-1){
							System.out.println();
						}
					}else{
						System.out.print(".");
					}
				}
			}
			System.out.println();
		}
	}
}