import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			if (h == 0 || w == 0) {
				sc.close();
				break;
			}
			System.out.println(createFrame(h, w));
		}
	}

	static String createFrame(int h, int w) {
		StringBuilder sb = new StringBuilder();
		createLine(w, sb);
		createMiddle(h, w, sb);
		createLine(w, sb);
		return sb.toString();
	}

	static StringBuilder createLine(int w, StringBuilder sb) {
		for (int i = 0; i < w; i++) {
			sb.append('#');
		}
		sb.append("\n");
		return sb;
	}

	static StringBuilder createMiddle(int h, int w, StringBuilder sb) {

		for (int i = 0; i < h - 2; i++) {
			sb.append('#');
			for (int j = 0; j < w - 2; j++) {
				sb.append('.');
			}
			sb.append("#\n");
		}
		return sb;
	}
} 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 h = sc.nextInt();
			int w = sc.nextInt();
			if (h == 0 || w == 0) {
				sc.close();
				break;
			}
			System.out.println(createFrame(h, w));
		}
	}

	static String createFrame(int h, int w) {
		StringBuilder sb = new StringBuilder();
		createLine(w, sb);
		createMiddle(h, w, sb);
		createLine(w, sb);
		return sb.toString();
	}

	static StringBuilder createLine(int w, StringBuilder sb) {
		for (int i = 0; i < w; i++) {
			sb.append('#');
		}
		sb.append("\n");
		return sb;
	}

	static StringBuilder createMiddle(int h, int w, StringBuilder sb) {

		for (int i = 0; i < h - 2; i++) {
			sb.append('#');
			for (int j = 0; j < w - 2; j++) {
				sb.append('.');
			}
			sb.append("#\n");
		}
		return sb;
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			if (h == 0 || w == 0) {
				sc.close();
				break;
			}
			System.out.println(createFrame(h, w));
		}
	} main {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			if (h == 0 || w == 0) {
				sc.close();
				break;
			}
			System.out.println(createFrame(h, w));
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			if (h == 0 || w == 0) {
				sc.close();
				break;
			}
			System.out.println(createFrame(h, w));
		} true {
			int h = sc.nextInt();
			int w = sc.nextInt();
			if (h == 0 || w == 0) {
				sc.close();
				break;
			}
			System.out.println(createFrame(h, w));
		} int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc int w = sc.nextInt(); w sc.nextInt() sc.nextInt sc if (h == 0 || w == 0) {
				sc.close();
				break;
			} h == 0 || w == 0 h == 0 h 0 w == 0 w 0 {
				sc.close();
				break;
			} sc.close() sc.close sc break; System.out.println(createFrame(h, w)) System.out.println System.out System System.out createFrame(h, w) createFrame h w String[] args args static String createFrame(int h, int w) {
		StringBuilder sb = new StringBuilder();
		createLine(w, sb);
		createMiddle(h, w, sb);
		createLine(w, sb);
		return sb.toString();
	} createFrame {
		StringBuilder sb = new StringBuilder();
		createLine(w, sb);
		createMiddle(h, w, sb);
		createLine(w, sb);
		return sb.toString();
	} StringBuilder sb = new StringBuilder(); sb new StringBuilder() createLine(w, sb) createLine w sb createMiddle(h, w, sb) createMiddle h w sb createLine(w, sb) createLine w sb return sb.toString(); sb.toString() sb.toString sb int h h int w w static StringBuilder createLine(int w, StringBuilder sb) {
		for (int i = 0; i < w; i++) {
			sb.append('#');
		}
		sb.append("\n");
		return sb;
	} createLine {
		for (int i = 0; i < w; i++) {
			sb.append('#');
		}
		sb.append("\n");
		return sb;
	} 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" return sb; sb int w w StringBuilder sb sb static StringBuilder createMiddle(int h, int w, StringBuilder sb) {

		for (int i = 0; i < h - 2; i++) {
			sb.append('#');
			for (int j = 0; j < w - 2; j++) {
				sb.append('.');
			}
			sb.append("#\n");
		}
		return sb;
	} createMiddle {

		for (int i = 0; i < h - 2; i++) {
			sb.append('#');
			for (int j = 0; j < w - 2; j++) {
				sb.append('.');
			}
			sb.append("#\n");
		}
		return sb;
	} for (int i = 0; i < h - 2; i++) {
			sb.append('#');
			for (int j = 0; j < w - 2; j++) {
				sb.append('.');
			}
			sb.append("#\n");
		} int i = 0; int i = 0; i 0 i < h - 2 i h - 2 h 2 i++ i++ i {
			sb.append('#');
			for (int j = 0; j < w - 2; j++) {
				sb.append('.');
			}
			sb.append("#\n");
		} {
			sb.append('#');
			for (int j = 0; j < w - 2; j++) {
				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("#\n") sb.append sb "#\n" return sb; sb int h h int w w StringBuilder sb sb public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			if (h == 0 || w == 0) {
				sc.close();
				break;
			}
			System.out.println(createFrame(h, w));
		}
	}

	static String createFrame(int h, int w) {
		StringBuilder sb = new StringBuilder();
		createLine(w, sb);
		createMiddle(h, w, sb);
		createLine(w, sb);
		return sb.toString();
	}

	static StringBuilder createLine(int w, StringBuilder sb) {
		for (int i = 0; i < w; i++) {
			sb.append('#');
		}
		sb.append("\n");
		return sb;
	}

	static StringBuilder createMiddle(int h, int w, StringBuilder sb) {

		for (int i = 0; i < h - 2; i++) {
			sb.append('#');
			for (int j = 0; j < w - 2; j++) {
				sb.append('.');
			}
			sb.append("#\n");
		}
		return sb;
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			if (h == 0 || w == 0) {
				sc.close();
				break;
			}
			System.out.println(createFrame(h, w));
		}
	}

	static String createFrame(int h, int w) {
		StringBuilder sb = new StringBuilder();
		createLine(w, sb);
		createMiddle(h, w, sb);
		createLine(w, sb);
		return sb.toString();
	}

	static StringBuilder createLine(int w, StringBuilder sb) {
		for (int i = 0; i < w; i++) {
			sb.append('#');
		}
		sb.append("\n");
		return sb;
	}

	static StringBuilder createMiddle(int h, int w, StringBuilder sb) {

		for (int i = 0; i < h - 2; i++) {
			sb.append('#');
			for (int j = 0; j < w - 2; j++) {
				sb.append('.');
			}
			sb.append("#\n");
		}
		return sb;
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			if (h == 0 || w == 0) {
				sc.close();
				break;
			}
			System.out.println(createFrame(h, w));
		}
	}

	static String createFrame(int h, int w) {
		StringBuilder sb = new StringBuilder();
		createLine(w, sb);
		createMiddle(h, w, sb);
		createLine(w, sb);
		return sb.toString();
	}

	static StringBuilder createLine(int w, StringBuilder sb) {
		for (int i = 0; i < w; i++) {
			sb.append('#');
		}
		sb.append("\n");
		return sb;
	}

	static StringBuilder createMiddle(int h, int w, StringBuilder sb) {

		for (int i = 0; i < h - 2; i++) {
			sb.append('#');
			for (int j = 0; j < w - 2; j++) {
				sb.append('.');
			}
			sb.append("#\n");
		}
		return sb;
	}
}