
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str;
		String[] arrStr;
		StringBuilder sb = new StringBuilder();
		try {


			while (true) {
				str = br.readLine();
				arrStr = str.split(" ");

				int h = Integer.parseInt(arrStr[0]);
				int w = Integer.parseInt(arrStr[1]);
				if (h == 0 && w == 0) {
					break;
				}
				for (int i = 0; i < h; i++) {
					for (int j = 0; j < w; j++) {
						if (   (i == 0 || j == 0)
							|| ((i == h - 1) || j == w - 1)) {
							sb.append("#");
						}else{
							sb.append(".");
						}
					}
					sb.append("\n");
				}
				System.out.println(sb.toString());
				sb.setLength(0);
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str;
		String[] arrStr;
		StringBuilder sb = new StringBuilder();
		try {


			while (true) {
				str = br.readLine();
				arrStr = str.split(" ");

				int h = Integer.parseInt(arrStr[0]);
				int w = Integer.parseInt(arrStr[1]);
				if (h == 0 && w == 0) {
					break;
				}
				for (int i = 0; i < h; i++) {
					for (int j = 0; j < w; j++) {
						if (   (i == 0 || j == 0)
							|| ((i == h - 1) || j == w - 1)) {
							sb.append("#");
						}else{
							sb.append(".");
						}
					}
					sb.append("\n");
				}
				System.out.println(sb.toString());
				sb.setLength(0);
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} Main public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str;
		String[] arrStr;
		StringBuilder sb = new StringBuilder();
		try {


			while (true) {
				str = br.readLine();
				arrStr = str.split(" ");

				int h = Integer.parseInt(arrStr[0]);
				int w = Integer.parseInt(arrStr[1]);
				if (h == 0 && w == 0) {
					break;
				}
				for (int i = 0; i < h; i++) {
					for (int j = 0; j < w; j++) {
						if (   (i == 0 || j == 0)
							|| ((i == h - 1) || j == w - 1)) {
							sb.append("#");
						}else{
							sb.append(".");
						}
					}
					sb.append("\n");
				}
				System.out.println(sb.toString());
				sb.setLength(0);
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str;
		String[] arrStr;
		StringBuilder sb = new StringBuilder();
		try {


			while (true) {
				str = br.readLine();
				arrStr = str.split(" ");

				int h = Integer.parseInt(arrStr[0]);
				int w = Integer.parseInt(arrStr[1]);
				if (h == 0 && w == 0) {
					break;
				}
				for (int i = 0; i < h; i++) {
					for (int j = 0; j < w; j++) {
						if (   (i == 0 || j == 0)
							|| ((i == h - 1) || j == w - 1)) {
							sb.append("#");
						}else{
							sb.append(".");
						}
					}
					sb.append("\n");
				}
				System.out.println(sb.toString());
				sb.setLength(0);
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str; str String[] arrStr; arrStr StringBuilder sb = new StringBuilder(); sb new StringBuilder() try {


			while (true) {
				str = br.readLine();
				arrStr = str.split(" ");

				int h = Integer.parseInt(arrStr[0]);
				int w = Integer.parseInt(arrStr[1]);
				if (h == 0 && w == 0) {
					break;
				}
				for (int i = 0; i < h; i++) {
					for (int j = 0; j < w; j++) {
						if (   (i == 0 || j == 0)
							|| ((i == h - 1) || j == w - 1)) {
							sb.append("#");
						}else{
							sb.append(".");
						}
					}
					sb.append("\n");
				}
				System.out.println(sb.toString());
				sb.setLength(0);
			}

		} catch (IOException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {


			while (true) {
				str = br.readLine();
				arrStr = str.split(" ");

				int h = Integer.parseInt(arrStr[0]);
				int w = Integer.parseInt(arrStr[1]);
				if (h == 0 && w == 0) {
					break;
				}
				for (int i = 0; i < h; i++) {
					for (int j = 0; j < w; j++) {
						if (   (i == 0 || j == 0)
							|| ((i == h - 1) || j == w - 1)) {
							sb.append("#");
						}else{
							sb.append(".");
						}
					}
					sb.append("\n");
				}
				System.out.println(sb.toString());
				sb.setLength(0);
			}

		} while (true) {
				str = br.readLine();
				arrStr = str.split(" ");

				int h = Integer.parseInt(arrStr[0]);
				int w = Integer.parseInt(arrStr[1]);
				if (h == 0 && w == 0) {
					break;
				}
				for (int i = 0; i < h; i++) {
					for (int j = 0; j < w; j++) {
						if (   (i == 0 || j == 0)
							|| ((i == h - 1) || j == w - 1)) {
							sb.append("#");
						}else{
							sb.append(".");
						}
					}
					sb.append("\n");
				}
				System.out.println(sb.toString());
				sb.setLength(0);
			} true {
				str = br.readLine();
				arrStr = str.split(" ");

				int h = Integer.parseInt(arrStr[0]);
				int w = Integer.parseInt(arrStr[1]);
				if (h == 0 && w == 0) {
					break;
				}
				for (int i = 0; i < h; i++) {
					for (int j = 0; j < w; j++) {
						if (   (i == 0 || j == 0)
							|| ((i == h - 1) || j == w - 1)) {
							sb.append("#");
						}else{
							sb.append(".");
						}
					}
					sb.append("\n");
				}
				System.out.println(sb.toString());
				sb.setLength(0);
			} str = br.readLine() str br.readLine() br.readLine br arrStr = str.split(" ") arrStr str.split(" ") str.split str " " int h = Integer.parseInt(arrStr[0]); h Integer.parseInt(arrStr[0]) Integer.parseInt Integer arrStr[0] arrStr 0 int w = Integer.parseInt(arrStr[1]); w Integer.parseInt(arrStr[1]) Integer.parseInt Integer arrStr[1] arrStr 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 < h; i++) {
					for (int j = 0; j < w; j++) {
						if (   (i == 0 || j == 0)
							|| ((i == h - 1) || j == w - 1)) {
							sb.append("#");
						}else{
							sb.append(".");
						}
					}
					sb.append("\n");
				} 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)
							|| ((i == h - 1) || j == w - 1)) {
							sb.append("#");
						}else{
							sb.append(".");
						}
					}
					sb.append("\n");
				} {
					for (int j = 0; j < w; j++) {
						if (   (i == 0 || j == 0)
							|| ((i == h - 1) || j == w - 1)) {
							sb.append("#");
						}else{
							sb.append(".");
						}
					}
					sb.append("\n");
				} for (int j = 0; j < w; j++) {
						if (   (i == 0 || j == 0)
							|| ((i == h - 1) || j == w - 1)) {
							sb.append("#");
						}else{
							sb.append(".");
						}
					} int j = 0; int j = 0; j 0 j < w j w j++ j++ j {
						if (   (i == 0 || j == 0)
							|| ((i == h - 1) || j == w - 1)) {
							sb.append("#");
						}else{
							sb.append(".");
						}
					} {
						if (   (i == 0 || j == 0)
							|| ((i == h - 1) || j == w - 1)) {
							sb.append("#");
						}else{
							sb.append(".");
						}
					} if (   (i == 0 || j == 0)
							|| ((i == h - 1) || j == w - 1)) {
							sb.append("#");
						}else{
							sb.append(".");
						} (i == 0 || j == 0)
							|| ((i == h - 1) || j == w - 1) (i == 0 || j == 0) i == 0 i 0 j == 0 j 0 ((i == h - 1) || j == w - 1) (i == h - 1) i h - 1 h 1 j == w - 1 j w - 1 w 1 {
							sb.append("#");
						} sb.append("#") sb.append sb "#" {
							sb.append(".");
						} sb.append(".") sb.append sb "." sb.append("\n") sb.append sb "\n" System.out.println(sb.toString()) System.out.println System.out System System.out sb.toString() sb.toString sb sb.setLength(0) sb.setLength sb 0 String[] args args public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str;
		String[] arrStr;
		StringBuilder sb = new StringBuilder();
		try {


			while (true) {
				str = br.readLine();
				arrStr = str.split(" ");

				int h = Integer.parseInt(arrStr[0]);
				int w = Integer.parseInt(arrStr[1]);
				if (h == 0 && w == 0) {
					break;
				}
				for (int i = 0; i < h; i++) {
					for (int j = 0; j < w; j++) {
						if (   (i == 0 || j == 0)
							|| ((i == h - 1) || j == w - 1)) {
							sb.append("#");
						}else{
							sb.append(".");
						}
					}
					sb.append("\n");
				}
				System.out.println(sb.toString());
				sb.setLength(0);
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str;
		String[] arrStr;
		StringBuilder sb = new StringBuilder();
		try {


			while (true) {
				str = br.readLine();
				arrStr = str.split(" ");

				int h = Integer.parseInt(arrStr[0]);
				int w = Integer.parseInt(arrStr[1]);
				if (h == 0 && w == 0) {
					break;
				}
				for (int i = 0; i < h; i++) {
					for (int j = 0; j < w; j++) {
						if (   (i == 0 || j == 0)
							|| ((i == h - 1) || j == w - 1)) {
							sb.append("#");
						}else{
							sb.append(".");
						}
					}
					sb.append("\n");
				}
				System.out.println(sb.toString());
				sb.setLength(0);
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} Main

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str;
		String[] arrStr;
		StringBuilder sb = new StringBuilder();
		try {


			while (true) {
				str = br.readLine();
				arrStr = str.split(" ");

				int h = Integer.parseInt(arrStr[0]);
				int w = Integer.parseInt(arrStr[1]);
				if (h == 0 && w == 0) {
					break;
				}
				for (int i = 0; i < h; i++) {
					for (int j = 0; j < w; j++) {
						if (   (i == 0 || j == 0)
							|| ((i == h - 1) || j == w - 1)) {
							sb.append("#");
						}else{
							sb.append(".");
						}
					}
					sb.append("\n");
				}
				System.out.println(sb.toString());
				sb.setLength(0);
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}