import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		for(;;){

			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0){

				scan.close();
				break;
			}
			for(int i=0; i<H; i++){ //縦の列の繰り返し

				for(int s=0; s<W; s++){ //横の行の繰り返し

					if(i == 0 | i == H-1){ //1行または最終行の指定
						System.out.print("#");
					}else if(s == 0 | s == W-1){ //1列または最終列の指定

						System.out.print("#");
					}else{
						
						System.out.print(".");
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
} import java.util.Scanner; Scanner java.util class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		for(;;){

			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0){

				scan.close();
				break;
			}
			for(int i=0; i<H; i++){ //縦の列の繰り返し

				for(int s=0; s<W; s++){ //横の行の繰り返し

					if(i == 0 | i == H-1){ //1行または最終行の指定
						System.out.print("#");
					}else if(s == 0 | s == W-1){ //1列または最終列の指定

						System.out.print("#");
					}else{
						
						System.out.print(".");
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
} Main public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		for(;;){

			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0){

				scan.close();
				break;
			}
			for(int i=0; i<H; i++){ //縦の列の繰り返し

				for(int s=0; s<W; s++){ //横の行の繰り返し

					if(i == 0 | i == H-1){ //1行または最終行の指定
						System.out.print("#");
					}else if(s == 0 | s == W-1){ //1列または最終列の指定

						System.out.print("#");
					}else{
						
						System.out.print(".");
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	} main {

		Scanner scan = new Scanner(System.in);

		for(;;){

			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0){

				scan.close();
				break;
			}
			for(int i=0; i<H; i++){ //縦の列の繰り返し

				for(int s=0; s<W; s++){ //横の行の繰り返し

					if(i == 0 | i == H-1){ //1行または最終行の指定
						System.out.print("#");
					}else if(s == 0 | s == W-1){ //1列または最終列の指定

						System.out.print("#");
					}else{
						
						System.out.print(".");
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) for(;;){

			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0){

				scan.close();
				break;
			}
			for(int i=0; i<H; i++){ //縦の列の繰り返し

				for(int s=0; s<W; s++){ //横の行の繰り返し

					if(i == 0 | i == H-1){ //1行または最終行の指定
						System.out.print("#");
					}else if(s == 0 | s == W-1){ //1列または最終列の指定

						System.out.print("#");
					}else{
						
						System.out.print(".");
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		} ; {

			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0){

				scan.close();
				break;
			}
			for(int i=0; i<H; i++){ //縦の列の繰り返し

				for(int s=0; s<W; s++){ //横の行の繰り返し

					if(i == 0 | i == H-1){ //1行または最終行の指定
						System.out.print("#");
					}else if(s == 0 | s == W-1){ //1列または最終列の指定

						System.out.print("#");
					}else{
						
						System.out.print(".");
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		} {

			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0){

				scan.close();
				break;
			}
			for(int i=0; i<H; i++){ //縦の列の繰り返し

				for(int s=0; s<W; s++){ //横の行の繰り返し

					if(i == 0 | i == H-1){ //1行または最終行の指定
						System.out.print("#");
					}else if(s == 0 | s == W-1){ //1列または最終列の指定

						System.out.print("#");
					}else{
						
						System.out.print(".");
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		} 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){

				scan.close();
				break;
			} H == 0 && W == 0 H == 0 H 0 W == 0 W 0 {

				scan.close();
				break;
			} scan.close() scan.close scan break; for(int i=0; i<H; i++){ //縦の列の繰り返し

				for(int s=0; s<W; s++){ //横の行の繰り返し

					if(i == 0 | i == H-1){ //1行または最終行の指定
						System.out.print("#");
					}else if(s == 0 | s == W-1){ //1列または最終列の指定

						System.out.print("#");
					}else{
						
						System.out.print(".");
					}
				}
				System.out.print("\n");
			} int i=0; int i=0; i 0 i<H i H i++ i++ i { //縦の列の繰り返し

				for(int s=0; s<W; s++){ //横の行の繰り返し

					if(i == 0 | i == H-1){ //1行または最終行の指定
						System.out.print("#");
					}else if(s == 0 | s == W-1){ //1列または最終列の指定

						System.out.print("#");
					}else{
						
						System.out.print(".");
					}
				}
				System.out.print("\n");
			} { //縦の列の繰り返し

				for(int s=0; s<W; s++){ //横の行の繰り返し

					if(i == 0 | i == H-1){ //1行または最終行の指定
						System.out.print("#");
					}else if(s == 0 | s == W-1){ //1列または最終列の指定

						System.out.print("#");
					}else{
						
						System.out.print(".");
					}
				}
				System.out.print("\n");
			} for(int s=0; s<W; s++){ //横の行の繰り返し

					if(i == 0 | i == H-1){ //1行または最終行の指定
						System.out.print("#");
					}else if(s == 0 | s == W-1){ //1列または最終列の指定

						System.out.print("#");
					}else{
						
						System.out.print(".");
					}
				} int s=0; int s=0; s 0 s<W s W s++ s++ s { //横の行の繰り返し

					if(i == 0 | i == H-1){ //1行または最終行の指定
						System.out.print("#");
					}else if(s == 0 | s == W-1){ //1列または最終列の指定

						System.out.print("#");
					}else{
						
						System.out.print(".");
					}
				} { //横の行の繰り返し

					if(i == 0 | i == H-1){ //1行または最終行の指定
						System.out.print("#");
					}else if(s == 0 | s == W-1){ //1列または最終列の指定

						System.out.print("#");
					}else{
						
						System.out.print(".");
					}
				} if(i == 0 | i == H-1){ //1行または最終行の指定
						System.out.print("#");
					}else if(s == 0 | s == W-1){ //1列または最終列の指定

						System.out.print("#");
					}else{
						
						System.out.print(".");
					} i == 0 | i == H-1 i == 0 i 0 i == H-1 i H-1 H 1 { //1行または最終行の指定
						System.out.print("#");
					} System.out.print("#") System.out.print System.out System System.out "#" if(s == 0 | s == W-1){ //1列または最終列の指定

						System.out.print("#");
					}else{
						
						System.out.print(".");
					} s == 0 | s == W-1 s == 0 s 0 s == W-1 s W-1 W 1 { //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.print("\n") System.out.print System.out System System.out "\n" System.out.print("\n") System.out.print System.out System System.out "\n" String[] args args
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		for(;;){

			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0){

				scan.close();
				break;
			}
			for(int i=0; i<H; i++){ //縦の列の繰り返し

				for(int s=0; s<W; s++){ //横の行の繰り返し

					if(i == 0 | i == H-1){ //1行または最終行の指定
						System.out.print("#");
					}else if(s == 0 | s == W-1){ //1列または最終列の指定

						System.out.print("#");
					}else{
						
						System.out.print(".");
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
}