import java.io.IOException;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {

		Scanner scane = new Scanner(System.in);

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

		do {

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

			H = scane.nextInt();

			W= scane.nextInt();


		} while (H !=0 && W !=0);
	}
} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util class Main {

	public static void main(String[] args) throws IOException {

		Scanner scane = new Scanner(System.in);

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

		do {

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

			H = scane.nextInt();

			W= scane.nextInt();


		} while (H !=0 && W !=0);
	}
} Main public static void main(String[] args) throws IOException {

		Scanner scane = new Scanner(System.in);

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

		do {

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

			H = scane.nextInt();

			W= scane.nextInt();


		} while (H !=0 && W !=0);
	} main {

		Scanner scane = new Scanner(System.in);

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

		do {

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

			H = scane.nextInt();

			W= scane.nextInt();


		} while (H !=0 && W !=0);
	} Scanner scane = new Scanner(System.in); scane new Scanner(System.in) int H =scane.nextInt(); H scane.nextInt() scane.nextInt scane int W =scane.nextInt(); W scane.nextInt() scane.nextInt scane do {

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

			H = scane.nextInt();

			W= scane.nextInt();


		} while (H !=0 && W !=0); H !=0 && W !=0 H !=0 H 0 W !=0 W 0 {

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

			H = scane.nextInt();

			W= scane.nextInt();


		} for(int i =0; i<H; i++){
				for (int j = 0; j < W; j++) {
					if(i ==0 && j >=0){
						System.out.print("#");
					}else if (i==(H-1) && j >= 0) {
						System.out.print("#");
					}else if (i >= 1 && j ==0) {
						System.out.print("#");
					}else if ( i>=1 && j == (W-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 j = 0; j < W; j++) {
					if(i ==0 && j >=0){
						System.out.print("#");
					}else if (i==(H-1) && j >= 0) {
						System.out.print("#");
					}else if (i >= 1 && j ==0) {
						System.out.print("#");
					}else if ( i>=1 && j == (W-1)) {
						System.out.print("#");
					}else {
						System.out.print(".");
					}
				}
				System.out.println();
			} {
				for (int j = 0; j < W; j++) {
					if(i ==0 && j >=0){
						System.out.print("#");
					}else if (i==(H-1) && j >= 0) {
						System.out.print("#");
					}else if (i >= 1 && j ==0) {
						System.out.print("#");
					}else if ( i>=1 && j == (W-1)) {
						System.out.print("#");
					}else {
						System.out.print(".");
					}
				}
				System.out.println();
			} for (int j = 0; j < W; j++) {
					if(i ==0 && j >=0){
						System.out.print("#");
					}else if (i==(H-1) && j >= 0) {
						System.out.print("#");
					}else if (i >= 1 && j ==0) {
						System.out.print("#");
					}else if ( i>=1 && j == (W-1)) {
						System.out.print("#");
					}else {
						System.out.print(".");
					}
				} int j = 0; int j = 0; j 0 j < W j W j++ j++ j {
					if(i ==0 && j >=0){
						System.out.print("#");
					}else if (i==(H-1) && j >= 0) {
						System.out.print("#");
					}else if (i >= 1 && j ==0) {
						System.out.print("#");
					}else if ( i>=1 && j == (W-1)) {
						System.out.print("#");
					}else {
						System.out.print(".");
					}
				} {
					if(i ==0 && j >=0){
						System.out.print("#");
					}else if (i==(H-1) && j >= 0) {
						System.out.print("#");
					}else if (i >= 1 && j ==0) {
						System.out.print("#");
					}else if ( i>=1 && j == (W-1)) {
						System.out.print("#");
					}else {
						System.out.print(".");
					}
				} if(i ==0 && j >=0){
						System.out.print("#");
					}else if (i==(H-1) && j >= 0) {
						System.out.print("#");
					}else if (i >= 1 && j ==0) {
						System.out.print("#");
					}else if ( i>=1 && j == (W-1)) {
						System.out.print("#");
					}else {
						System.out.print(".");
					} i ==0 && j >=0 i ==0 i 0 j >=0 j 0 {
						System.out.print("#");
					} System.out.print("#") System.out.print System.out System System.out "#" if (i==(H-1) && j >= 0) {
						System.out.print("#");
					}else if (i >= 1 && j ==0) {
						System.out.print("#");
					}else if ( i>=1 && j == (W-1)) {
						System.out.print("#");
					}else {
						System.out.print(".");
					} i==(H-1) && j >= 0 i==(H-1) i (H-1) H 1 j >= 0 j 0 {
						System.out.print("#");
					} System.out.print("#") System.out.print System.out System System.out "#" if (i >= 1 && j ==0) {
						System.out.print("#");
					}else if ( i>=1 && j == (W-1)) {
						System.out.print("#");
					}else {
						System.out.print(".");
					} i >= 1 && j ==0 i >= 1 i 1 j ==0 j 0 {
						System.out.print("#");
					} System.out.print("#") System.out.print System.out System System.out "#" if ( i>=1 && j == (W-1)) {
						System.out.print("#");
					}else {
						System.out.print(".");
					} i>=1 && j == (W-1) i>=1 i 1 j == (W-1) j (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 = scane.nextInt() H scane.nextInt() scane.nextInt scane W= scane.nextInt() W scane.nextInt() scane.nextInt scane String[] args args
import java.io.IOException;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {

		Scanner scane = new Scanner(System.in);

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

		do {

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

			H = scane.nextInt();

			W= scane.nextInt();


		} while (H !=0 && W !=0);
	}
}