import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(int a = 1;a>0;a++){
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W == 0){
				break;
			}
			for(int b = 0;b<H;b++){
				if(b==0 || b==(H-1)){
					for(int c =0;c<W;c++){
						System.out.print("#");
					}
				}else{
					for(int d = 0;d<W;d++){
						if(d == 0 || d == (W-1)){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(int a = 1;a>0;a++){
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W == 0){
				break;
			}
			for(int b = 0;b<H;b++){
				if(b==0 || b==(H-1)){
					for(int c =0;c<W;c++){
						System.out.print("#");
					}
				}else{
					for(int d = 0;d<W;d++){
						if(d == 0 || d == (W-1)){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
} Main public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(int a = 1;a>0;a++){
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W == 0){
				break;
			}
			for(int b = 0;b<H;b++){
				if(b==0 || b==(H-1)){
					for(int c =0;c<W;c++){
						System.out.print("#");
					}
				}else{
					for(int d = 0;d<W;d++){
						if(d == 0 || d == (W-1)){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	} main {
		Scanner scan = new Scanner(System.in);
		for(int a = 1;a>0;a++){
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W == 0){
				break;
			}
			for(int b = 0;b<H;b++){
				if(b==0 || b==(H-1)){
					for(int c =0;c<W;c++){
						System.out.print("#");
					}
				}else{
					for(int d = 0;d<W;d++){
						if(d == 0 || d == (W-1)){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) for(int a = 1;a>0;a++){
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W == 0){
				break;
			}
			for(int b = 0;b<H;b++){
				if(b==0 || b==(H-1)){
					for(int c =0;c<W;c++){
						System.out.print("#");
					}
				}else{
					for(int d = 0;d<W;d++){
						if(d == 0 || d == (W-1)){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.println("");
			}
			System.out.println("");
		} int a = 1; int a = 1; a 1 a>0 a 0 a++ a++ a {
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W == 0){
				break;
			}
			for(int b = 0;b<H;b++){
				if(b==0 || b==(H-1)){
					for(int c =0;c<W;c++){
						System.out.print("#");
					}
				}else{
					for(int d = 0;d<W;d++){
						if(d == 0 || d == (W-1)){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.println("");
			}
			System.out.println("");
		} {
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W == 0){
				break;
			}
			for(int b = 0;b<H;b++){
				if(b==0 || b==(H-1)){
					for(int c =0;c<W;c++){
						System.out.print("#");
					}
				}else{
					for(int d = 0;d<W;d++){
						if(d == 0 || d == (W-1)){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.println("");
			}
			System.out.println("");
		} int H = scan.nextInt(); H scan.nextInt() scan.nextInt scan int W = scan.nextInt(); W scan.nextInt() scan.nextInt scan if(H == 0 && W == 0){
				break;
			} H == 0 && W == 0 H == 0 H 0 W == 0 W 0 {
				break;
			} break; for(int b = 0;b<H;b++){
				if(b==0 || b==(H-1)){
					for(int c =0;c<W;c++){
						System.out.print("#");
					}
				}else{
					for(int d = 0;d<W;d++){
						if(d == 0 || d == (W-1)){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.println("");
			} int b = 0; int b = 0; b 0 b<H b H b++ b++ b {
				if(b==0 || b==(H-1)){
					for(int c =0;c<W;c++){
						System.out.print("#");
					}
				}else{
					for(int d = 0;d<W;d++){
						if(d == 0 || d == (W-1)){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.println("");
			} {
				if(b==0 || b==(H-1)){
					for(int c =0;c<W;c++){
						System.out.print("#");
					}
				}else{
					for(int d = 0;d<W;d++){
						if(d == 0 || d == (W-1)){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.println("");
			} if(b==0 || b==(H-1)){
					for(int c =0;c<W;c++){
						System.out.print("#");
					}
				}else{
					for(int d = 0;d<W;d++){
						if(d == 0 || d == (W-1)){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				} b==0 || b==(H-1) b==0 b 0 b==(H-1) b (H-1) H 1 {
					for(int c =0;c<W;c++){
						System.out.print("#");
					}
				} for(int c =0;c<W;c++){
						System.out.print("#");
					} int c =0; int c =0; c 0 c<W c W c++ c++ c {
						System.out.print("#");
					} {
						System.out.print("#");
					} System.out.print("#") System.out.print System.out System System.out "#" {
					for(int d = 0;d<W;d++){
						if(d == 0 || d == (W-1)){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				} for(int d = 0;d<W;d++){
						if(d == 0 || d == (W-1)){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					} int d = 0; int d = 0; d 0 d<W d W d++ d++ d {
						if(d == 0 || d == (W-1)){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					} {
						if(d == 0 || d == (W-1)){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					} if(d == 0 || d == (W-1)){
							System.out.print("#");
						}else{
							System.out.print(".");
						} d == 0 || d == (W-1) d == 0 d 0 d == (W-1) d (W-1) W 1 {
							System.out.print("#");
						} System.out.print("#") System.out.print 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 "" System.out.println("") System.out.println System.out System System.out "" String[] args args public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(int a = 1;a>0;a++){
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W == 0){
				break;
			}
			for(int b = 0;b<H;b++){
				if(b==0 || b==(H-1)){
					for(int c =0;c<W;c++){
						System.out.print("#");
					}
				}else{
					for(int d = 0;d<W;d++){
						if(d == 0 || d == (W-1)){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
} public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(int a = 1;a>0;a++){
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W == 0){
				break;
			}
			for(int b = 0;b<H;b++){
				if(b==0 || b==(H-1)){
					for(int c =0;c<W;c++){
						System.out.print("#");
					}
				}else{
					for(int d = 0;d<W;d++){
						if(d == 0 || d == (W-1)){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(int a = 1;a>0;a++){
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W == 0){
				break;
			}
			for(int b = 0;b<H;b++){
				if(b==0 || b==(H-1)){
					for(int c =0;c<W;c++){
						System.out.print("#");
					}
				}else{
					for(int d = 0;d<W;d++){
						if(d == 0 || d == (W-1)){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}