import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		while (true) {
			String[] cut = br.readLine().split(" ");
			int H = Integer.parseInt(cut[0]);
			int W = Integer.parseInt(cut[1]);
			if (H == 0 && W == 0){
				break;
			}
			for (int i = 0; i < W; i++) {
				sb.append("#");

			}
			sb.append("\n");
			for (int k = 0; k < H-2; k++) {
				sb.append("#");
				for (int j = 0; j < W - 2; j++) {
					sb.append(".");
				}
				sb.append("#");
				sb.append("\n");
			}
			for (int i = 0; i < W; i++) {
				sb.append("#");
			}
			sb.append("\n");
			sb.append("\n");
		}
		System.out.print(sb);

	}

} import java.io.*; io.* java class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		while (true) {
			String[] cut = br.readLine().split(" ");
			int H = Integer.parseInt(cut[0]);
			int W = Integer.parseInt(cut[1]);
			if (H == 0 && W == 0){
				break;
			}
			for (int i = 0; i < W; i++) {
				sb.append("#");

			}
			sb.append("\n");
			for (int k = 0; k < H-2; k++) {
				sb.append("#");
				for (int j = 0; j < W - 2; j++) {
					sb.append(".");
				}
				sb.append("#");
				sb.append("\n");
			}
			for (int i = 0; i < W; i++) {
				sb.append("#");
			}
			sb.append("\n");
			sb.append("\n");
		}
		System.out.print(sb);

	}

} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		while (true) {
			String[] cut = br.readLine().split(" ");
			int H = Integer.parseInt(cut[0]);
			int W = Integer.parseInt(cut[1]);
			if (H == 0 && W == 0){
				break;
			}
			for (int i = 0; i < W; i++) {
				sb.append("#");

			}
			sb.append("\n");
			for (int k = 0; k < H-2; k++) {
				sb.append("#");
				for (int j = 0; j < W - 2; j++) {
					sb.append(".");
				}
				sb.append("#");
				sb.append("\n");
			}
			for (int i = 0; i < W; i++) {
				sb.append("#");
			}
			sb.append("\n");
			sb.append("\n");
		}
		System.out.print(sb);

	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		while (true) {
			String[] cut = br.readLine().split(" ");
			int H = Integer.parseInt(cut[0]);
			int W = Integer.parseInt(cut[1]);
			if (H == 0 && W == 0){
				break;
			}
			for (int i = 0; i < W; i++) {
				sb.append("#");

			}
			sb.append("\n");
			for (int k = 0; k < H-2; k++) {
				sb.append("#");
				for (int j = 0; j < W - 2; j++) {
					sb.append(".");
				}
				sb.append("#");
				sb.append("\n");
			}
			for (int i = 0; i < W; i++) {
				sb.append("#");
			}
			sb.append("\n");
			sb.append("\n");
		}
		System.out.print(sb);

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() while (true) {
			String[] cut = br.readLine().split(" ");
			int H = Integer.parseInt(cut[0]);
			int W = Integer.parseInt(cut[1]);
			if (H == 0 && W == 0){
				break;
			}
			for (int i = 0; i < W; i++) {
				sb.append("#");

			}
			sb.append("\n");
			for (int k = 0; k < H-2; k++) {
				sb.append("#");
				for (int j = 0; j < W - 2; j++) {
					sb.append(".");
				}
				sb.append("#");
				sb.append("\n");
			}
			for (int i = 0; i < W; i++) {
				sb.append("#");
			}
			sb.append("\n");
			sb.append("\n");
		} true {
			String[] cut = br.readLine().split(" ");
			int H = Integer.parseInt(cut[0]);
			int W = Integer.parseInt(cut[1]);
			if (H == 0 && W == 0){
				break;
			}
			for (int i = 0; i < W; i++) {
				sb.append("#");

			}
			sb.append("\n");
			for (int k = 0; k < H-2; k++) {
				sb.append("#");
				for (int j = 0; j < W - 2; j++) {
					sb.append(".");
				}
				sb.append("#");
				sb.append("\n");
			}
			for (int i = 0; i < W; i++) {
				sb.append("#");
			}
			sb.append("\n");
			sb.append("\n");
		} String[] cut = br.readLine().split(" "); cut br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int H = Integer.parseInt(cut[0]); H Integer.parseInt(cut[0]) Integer.parseInt Integer cut[0] cut 0 int W = Integer.parseInt(cut[1]); W Integer.parseInt(cut[1]) Integer.parseInt Integer cut[1] cut 1 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 < W; i++) {
				sb.append("#");

			} int i = 0; int i = 0; i 0 i < W i W i++ i++ i {
				sb.append("#");

			} {
				sb.append("#");

			} sb.append("#") sb.append sb "#" sb.append("\n") sb.append sb "\n" for (int k = 0; k < H-2; k++) {
				sb.append("#");
				for (int j = 0; j < W - 2; j++) {
					sb.append(".");
				}
				sb.append("#");
				sb.append("\n");
			} int k = 0; int k = 0; k 0 k < H-2 k H-2 H 2 k++ k++ k {
				sb.append("#");
				for (int j = 0; j < W - 2; j++) {
					sb.append(".");
				}
				sb.append("#");
				sb.append("\n");
			} {
				sb.append("#");
				for (int j = 0; j < W - 2; j++) {
					sb.append(".");
				}
				sb.append("#");
				sb.append("\n");
			} sb.append("#") sb.append sb "#" for (int j = 0; j < W - 2; j++) {
					sb.append(".");
				} int j = 0; int j = 0; j 0 j < W - 2 j W - 2 W 2 j++ j++ j {
					sb.append(".");
				} {
					sb.append(".");
				} sb.append(".") sb.append sb "." sb.append("#") sb.append sb "#" sb.append("\n") sb.append sb "\n" for (int i = 0; i < W; i++) {
				sb.append("#");
			} int i = 0; int i = 0; i 0 i < W i W i++ i++ i {
				sb.append("#");
			} {
				sb.append("#");
			} sb.append("#") sb.append sb "#" sb.append("\n") sb.append sb "\n" sb.append("\n") sb.append sb "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		while (true) {
			String[] cut = br.readLine().split(" ");
			int H = Integer.parseInt(cut[0]);
			int W = Integer.parseInt(cut[1]);
			if (H == 0 && W == 0){
				break;
			}
			for (int i = 0; i < W; i++) {
				sb.append("#");

			}
			sb.append("\n");
			for (int k = 0; k < H-2; k++) {
				sb.append("#");
				for (int j = 0; j < W - 2; j++) {
					sb.append(".");
				}
				sb.append("#");
				sb.append("\n");
			}
			for (int i = 0; i < W; i++) {
				sb.append("#");
			}
			sb.append("\n");
			sb.append("\n");
		}
		System.out.print(sb);

	}

}