import java.util.Scanner;
class Main {
	int H,W,x,y;
	public void suzuki(){
		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		while(H != 0 || W != 0){
			for(x = 0;x < H;x++){
				for(y = 0;y < W;y++){
					if(x == 0 || x == H - 1 || y == 0 || y == W - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
			H = sc.nextInt();
			W = sc.nextInt();
		}
	}
	public static void main(String[] args){
		new Main().suzuki();
	}
} import java.util.Scanner; Scanner java.util class Main {
	int H,W,x,y;
	public void suzuki(){
		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		while(H != 0 || W != 0){
			for(x = 0;x < H;x++){
				for(y = 0;y < W;y++){
					if(x == 0 || x == H - 1 || y == 0 || y == W - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
			H = sc.nextInt();
			W = sc.nextInt();
		}
	}
	public static void main(String[] args){
		new Main().suzuki();
	}
} Main int H H W W x x y; y public void suzuki(){
		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		while(H != 0 || W != 0){
			for(x = 0;x < H;x++){
				for(y = 0;y < W;y++){
					if(x == 0 || x == H - 1 || y == 0 || y == W - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
			H = sc.nextInt();
			W = sc.nextInt();
		}
	} suzuki {
		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		while(H != 0 || W != 0){
			for(x = 0;x < H;x++){
				for(y = 0;y < W;y++){
					if(x == 0 || x == H - 1 || y == 0 || y == W - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
			H = sc.nextInt();
			W = sc.nextInt();
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) H = sc.nextInt() H sc.nextInt() sc.nextInt sc W = sc.nextInt() W sc.nextInt() sc.nextInt sc while(H != 0 || W != 0){
			for(x = 0;x < H;x++){
				for(y = 0;y < W;y++){
					if(x == 0 || x == H - 1 || y == 0 || y == W - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
			H = sc.nextInt();
			W = sc.nextInt();
		} H != 0 || W != 0 H != 0 H 0 W != 0 W 0 {
			for(x = 0;x < H;x++){
				for(y = 0;y < W;y++){
					if(x == 0 || x == H - 1 || y == 0 || y == W - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
			H = sc.nextInt();
			W = sc.nextInt();
		} for(x = 0;x < H;x++){
				for(y = 0;y < W;y++){
					if(x == 0 || x == H - 1 || y == 0 || y == W - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println("");
			} x = 0; x = 0 x 0 x < H x H x++ x++ x {
				for(y = 0;y < W;y++){
					if(x == 0 || x == H - 1 || y == 0 || y == W - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println("");
			} {
				for(y = 0;y < W;y++){
					if(x == 0 || x == H - 1 || y == 0 || y == W - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println("");
			} for(y = 0;y < W;y++){
					if(x == 0 || x == H - 1 || y == 0 || y == W - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				} y = 0; y = 0 y 0 y < W y W y++ y++ y {
					if(x == 0 || x == H - 1 || y == 0 || y == W - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				} {
					if(x == 0 || x == H - 1 || y == 0 || y == W - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				} if(x == 0 || x == H - 1 || y == 0 || y == W - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
					} x == 0 || x == H - 1 || y == 0 || y == W - 1 y == 0 x == 0 || x == H - 1 || y == 0 || y == W - 1 x == 0 x 0 x == H - 1 x H - 1 H 1 y == 0 y 0 y == W - 1 y 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 "" H = sc.nextInt() H sc.nextInt() sc.nextInt sc W = sc.nextInt() W sc.nextInt() sc.nextInt sc public static void main(String[] args){
		new Main().suzuki();
	} main {
		new Main().suzuki();
	} new Main().suzuki() new Main().suzuki new Main() String[] args args
import java.util.Scanner;
class Main {
	int H,W,x,y;
	public void suzuki(){
		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		while(H != 0 || W != 0){
			for(x = 0;x < H;x++){
				for(y = 0;y < W;y++){
					if(x == 0 || x == H - 1 || y == 0 || y == W - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
			H = sc.nextInt();
			W = sc.nextInt();
		}
	}
	public static void main(String[] args){
		new Main().suzuki();
	}
}