import java.util.*;

class Main{
	public static void main(String args[]){
		int H, W;
		Scanner scan = new Scanner(System.in);

		while(true){
			H = scan.nextInt();
			W = scan.nextInt();
			
			if(H == 0 && W == 0){break;}

			for(int i=0; i<H; i++){
				for(int k=0; k<W; k++){
					if(k==0 || k ==(W-1) || i==0 || i==(H-1)){
						System.out.print("#");
					}
					else{
						System.out.print(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
} import java.util.*; util.* java class Main{
	public static void main(String args[]){
		int H, W;
		Scanner scan = new Scanner(System.in);

		while(true){
			H = scan.nextInt();
			W = scan.nextInt();
			
			if(H == 0 && W == 0){break;}

			for(int i=0; i<H; i++){
				for(int k=0; k<W; k++){
					if(k==0 || k ==(W-1) || i==0 || i==(H-1)){
						System.out.print("#");
					}
					else{
						System.out.print(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
} Main public static void main(String args[]){
		int H, W;
		Scanner scan = new Scanner(System.in);

		while(true){
			H = scan.nextInt();
			W = scan.nextInt();
			
			if(H == 0 && W == 0){break;}

			for(int i=0; i<H; i++){
				for(int k=0; k<W; k++){
					if(k==0 || k ==(W-1) || i==0 || i==(H-1)){
						System.out.print("#");
					}
					else{
						System.out.print(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	} main {
		int H, W;
		Scanner scan = new Scanner(System.in);

		while(true){
			H = scan.nextInt();
			W = scan.nextInt();
			
			if(H == 0 && W == 0){break;}

			for(int i=0; i<H; i++){
				for(int k=0; k<W; k++){
					if(k==0 || k ==(W-1) || i==0 || i==(H-1)){
						System.out.print("#");
					}
					else{
						System.out.print(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	} int H H W; W Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while(true){
			H = scan.nextInt();
			W = scan.nextInt();
			
			if(H == 0 && W == 0){break;}

			for(int i=0; i<H; i++){
				for(int k=0; k<W; k++){
					if(k==0 || k ==(W-1) || i==0 || i==(H-1)){
						System.out.print("#");
					}
					else{
						System.out.print(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
		} true {
			H = scan.nextInt();
			W = scan.nextInt();
			
			if(H == 0 && W == 0){break;}

			for(int i=0; i<H; i++){
				for(int k=0; k<W; k++){
					if(k==0 || k ==(W-1) || i==0 || i==(H-1)){
						System.out.print("#");
					}
					else{
						System.out.print(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
		} H = scan.nextInt() H scan.nextInt() scan.nextInt scan 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 i=0; i<H; i++){
				for(int k=0; k<W; k++){
					if(k==0 || k ==(W-1) || i==0 || i==(H-1)){
						System.out.print("#");
					}
					else{
						System.out.print(".");
					}
				}
				System.out.println("");
			} int i=0; int i=0; i 0 i<H i H i++ i++ i {
				for(int k=0; k<W; k++){
					if(k==0 || k ==(W-1) || i==0 || i==(H-1)){
						System.out.print("#");
					}
					else{
						System.out.print(".");
					}
				}
				System.out.println("");
			} {
				for(int k=0; k<W; k++){
					if(k==0 || k ==(W-1) || i==0 || i==(H-1)){
						System.out.print("#");
					}
					else{
						System.out.print(".");
					}
				}
				System.out.println("");
			} for(int k=0; k<W; k++){
					if(k==0 || k ==(W-1) || i==0 || i==(H-1)){
						System.out.print("#");
					}
					else{
						System.out.print(".");
					}
				} int k=0; int k=0; k 0 k<W k W k++ k++ k {
					if(k==0 || k ==(W-1) || i==0 || i==(H-1)){
						System.out.print("#");
					}
					else{
						System.out.print(".");
					}
				} {
					if(k==0 || k ==(W-1) || i==0 || i==(H-1)){
						System.out.print("#");
					}
					else{
						System.out.print(".");
					}
				} if(k==0 || k ==(W-1) || i==0 || i==(H-1)){
						System.out.print("#");
					}
					else{
						System.out.print(".");
					} k==0 || k ==(W-1) || i==0 || i==(H-1) i==0 k==0 || k ==(W-1) || i==0 || i==(H-1) k==0 k 0 k ==(W-1) k (W-1) W 1 i==0 i 0 i==(H-1) i (H-1) H 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
import java.util.*;

class Main{
	public static void main(String args[]){
		int H, W;
		Scanner scan = new Scanner(System.in);

		while(true){
			H = scan.nextInt();
			W = scan.nextInt();
			
			if(H == 0 && W == 0){break;}

			for(int i=0; i<H; i++){
				for(int k=0; k<W; k++){
					if(k==0 || k ==(W-1) || i==0 || i==(H-1)){
						System.out.print("#");
					}
					else{
						System.out.print(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}