import java.util.Scanner;

public class Main{
	public static void main(String args[]){

		//????????¨?¨???????????????????
		Scanner sc = new Scanner(System.in);
		while(true){
			int intH = sc.nextInt();
			int intW = sc.nextInt();
			int h = intH - 1;
			int w = intW - 1;

			//??????H???W???0?????£???????????????????????????
			if((intH == 0) && (intW == 0)){
				break;
			}
			//??????

			for (int i = 0; i < intH; i++) {
				String A = "";
				for (int j = 0; j < intW; j++) {
					if (i == 0 || i == h || j == 0 || j == w ) {
						A += "#";
					}else {
						A += ".";
					}
				}
				System.out.println(A);
			}
			System.out.println("");
		}
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String args[]){

		//????????¨?¨???????????????????
		Scanner sc = new Scanner(System.in);
		while(true){
			int intH = sc.nextInt();
			int intW = sc.nextInt();
			int h = intH - 1;
			int w = intW - 1;

			//??????H???W???0?????£???????????????????????????
			if((intH == 0) && (intW == 0)){
				break;
			}
			//??????

			for (int i = 0; i < intH; i++) {
				String A = "";
				for (int j = 0; j < intW; j++) {
					if (i == 0 || i == h || j == 0 || j == w ) {
						A += "#";
					}else {
						A += ".";
					}
				}
				System.out.println(A);
			}
			System.out.println("");
		}
	}
} Main public static void main(String args[]){

		//????????¨?¨???????????????????
		Scanner sc = new Scanner(System.in);
		while(true){
			int intH = sc.nextInt();
			int intW = sc.nextInt();
			int h = intH - 1;
			int w = intW - 1;

			//??????H???W???0?????£???????????????????????????
			if((intH == 0) && (intW == 0)){
				break;
			}
			//??????

			for (int i = 0; i < intH; i++) {
				String A = "";
				for (int j = 0; j < intW; j++) {
					if (i == 0 || i == h || j == 0 || j == w ) {
						A += "#";
					}else {
						A += ".";
					}
				}
				System.out.println(A);
			}
			System.out.println("");
		}
	} main {

		//????????¨?¨???????????????????
		Scanner sc = new Scanner(System.in);
		while(true){
			int intH = sc.nextInt();
			int intW = sc.nextInt();
			int h = intH - 1;
			int w = intW - 1;

			//??????H???W???0?????£???????????????????????????
			if((intH == 0) && (intW == 0)){
				break;
			}
			//??????

			for (int i = 0; i < intH; i++) {
				String A = "";
				for (int j = 0; j < intW; j++) {
					if (i == 0 || i == h || j == 0 || j == w ) {
						A += "#";
					}else {
						A += ".";
					}
				}
				System.out.println(A);
			}
			System.out.println("");
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
			int intH = sc.nextInt();
			int intW = sc.nextInt();
			int h = intH - 1;
			int w = intW - 1;

			//??????H???W???0?????£???????????????????????????
			if((intH == 0) && (intW == 0)){
				break;
			}
			//??????

			for (int i = 0; i < intH; i++) {
				String A = "";
				for (int j = 0; j < intW; j++) {
					if (i == 0 || i == h || j == 0 || j == w ) {
						A += "#";
					}else {
						A += ".";
					}
				}
				System.out.println(A);
			}
			System.out.println("");
		} true {
			int intH = sc.nextInt();
			int intW = sc.nextInt();
			int h = intH - 1;
			int w = intW - 1;

			//??????H???W???0?????£???????????????????????????
			if((intH == 0) && (intW == 0)){
				break;
			}
			//??????

			for (int i = 0; i < intH; i++) {
				String A = "";
				for (int j = 0; j < intW; j++) {
					if (i == 0 || i == h || j == 0 || j == w ) {
						A += "#";
					}else {
						A += ".";
					}
				}
				System.out.println(A);
			}
			System.out.println("");
		} int intH = sc.nextInt(); intH sc.nextInt() sc.nextInt sc int intW = sc.nextInt(); intW sc.nextInt() sc.nextInt sc int h = intH - 1; h intH - 1 intH 1 int w = intW - 1; w intW - 1 intW 1 if((intH == 0) && (intW == 0)){
				break;
			} (intH == 0) && (intW == 0) (intH == 0) intH 0 (intW == 0) intW 0 {
				break;
			} break; for (int i = 0; i < intH; i++) {
				String A = "";
				for (int j = 0; j < intW; j++) {
					if (i == 0 || i == h || j == 0 || j == w ) {
						A += "#";
					}else {
						A += ".";
					}
				}
				System.out.println(A);
			} int i = 0; int i = 0; i 0 i < intH i intH i++ i++ i {
				String A = "";
				for (int j = 0; j < intW; j++) {
					if (i == 0 || i == h || j == 0 || j == w ) {
						A += "#";
					}else {
						A += ".";
					}
				}
				System.out.println(A);
			} {
				String A = "";
				for (int j = 0; j < intW; j++) {
					if (i == 0 || i == h || j == 0 || j == w ) {
						A += "#";
					}else {
						A += ".";
					}
				}
				System.out.println(A);
			} String A = ""; A "" for (int j = 0; j < intW; j++) {
					if (i == 0 || i == h || j == 0 || j == w ) {
						A += "#";
					}else {
						A += ".";
					}
				} int j = 0; int j = 0; j 0 j < intW j intW j++ j++ j {
					if (i == 0 || i == h || j == 0 || j == w ) {
						A += "#";
					}else {
						A += ".";
					}
				} {
					if (i == 0 || i == h || j == 0 || j == w ) {
						A += "#";
					}else {
						A += ".";
					}
				} if (i == 0 || i == h || j == 0 || j == w ) {
						A += "#";
					}else {
						A += ".";
					} i == 0 || i == h || j == 0 || j == w j == 0 i == 0 || i == h || j == 0 || j == w i == 0 i 0 i == h i h j == 0 j 0 j == w j w {
						A += "#";
					} A += "#" A "#" {
						A += ".";
					} A += "." A "." System.out.println(A) System.out.println System.out System System.out A System.out.println("") System.out.println System.out System System.out "" String args[] args public class Main{
	public static void main(String args[]){

		//????????¨?¨???????????????????
		Scanner sc = new Scanner(System.in);
		while(true){
			int intH = sc.nextInt();
			int intW = sc.nextInt();
			int h = intH - 1;
			int w = intW - 1;

			//??????H???W???0?????£???????????????????????????
			if((intH == 0) && (intW == 0)){
				break;
			}
			//??????

			for (int i = 0; i < intH; i++) {
				String A = "";
				for (int j = 0; j < intW; j++) {
					if (i == 0 || i == h || j == 0 || j == w ) {
						A += "#";
					}else {
						A += ".";
					}
				}
				System.out.println(A);
			}
			System.out.println("");
		}
	}
} public class Main{
	public static void main(String args[]){

		//????????¨?¨???????????????????
		Scanner sc = new Scanner(System.in);
		while(true){
			int intH = sc.nextInt();
			int intW = sc.nextInt();
			int h = intH - 1;
			int w = intW - 1;

			//??????H???W???0?????£???????????????????????????
			if((intH == 0) && (intW == 0)){
				break;
			}
			//??????

			for (int i = 0; i < intH; i++) {
				String A = "";
				for (int j = 0; j < intW; j++) {
					if (i == 0 || i == h || j == 0 || j == w ) {
						A += "#";
					}else {
						A += ".";
					}
				}
				System.out.println(A);
			}
			System.out.println("");
		}
	}
} Main
import java.util.Scanner;

public class Main{
	public static void main(String args[]){

		//????????¨?¨???????????????????
		Scanner sc = new Scanner(System.in);
		while(true){
			int intH = sc.nextInt();
			int intW = sc.nextInt();
			int h = intH - 1;
			int w = intW - 1;

			//??????H???W???0?????£???????????????????????????
			if((intH == 0) && (intW == 0)){
				break;
			}
			//??????

			for (int i = 0; i < intH; i++) {
				String A = "";
				for (int j = 0; j < intW; j++) {
					if (i == 0 || i == h || j == 0 || j == w ) {
						A += "#";
					}else {
						A += ".";
					}
				}
				System.out.println(A);
			}
			System.out.println("");
		}
	}
}