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

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String strNum = "";
		ArrayList<String> waku = new ArrayList<String>();
		while (true) {
			strNum = br.readLine();
			if ("0 0".equals(strNum)) {
				break;
			}
			for (int i = 0; i < Integer.parseInt(strNum.split(" ")[0]); i++) {
				String line = "";
				if (i == 0 || i == (Integer.parseInt(strNum.split(" ")[0]) - 1)) {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						line += "#";
					}
				} else {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						if (j == 0 || j == (Integer.parseInt(strNum.split(" ")[1]) - 1)) {
							line += "#";
						} else {
							line += ".";
						}
					}
				}
				waku.add(line);
			}
			waku.add("");
		}
		for (int i = 0; i < waku.size(); i++) {
			System.out.println(waku.get(i));
		}
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String strNum = "";
		ArrayList<String> waku = new ArrayList<String>();
		while (true) {
			strNum = br.readLine();
			if ("0 0".equals(strNum)) {
				break;
			}
			for (int i = 0; i < Integer.parseInt(strNum.split(" ")[0]); i++) {
				String line = "";
				if (i == 0 || i == (Integer.parseInt(strNum.split(" ")[0]) - 1)) {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						line += "#";
					}
				} else {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						if (j == 0 || j == (Integer.parseInt(strNum.split(" ")[1]) - 1)) {
							line += "#";
						} else {
							line += ".";
						}
					}
				}
				waku.add(line);
			}
			waku.add("");
		}
		for (int i = 0; i < waku.size(); i++) {
			System.out.println(waku.get(i));
		}
	}

} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String strNum = "";
		ArrayList<String> waku = new ArrayList<String>();
		while (true) {
			strNum = br.readLine();
			if ("0 0".equals(strNum)) {
				break;
			}
			for (int i = 0; i < Integer.parseInt(strNum.split(" ")[0]); i++) {
				String line = "";
				if (i == 0 || i == (Integer.parseInt(strNum.split(" ")[0]) - 1)) {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						line += "#";
					}
				} else {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						if (j == 0 || j == (Integer.parseInt(strNum.split(" ")[1]) - 1)) {
							line += "#";
						} else {
							line += ".";
						}
					}
				}
				waku.add(line);
			}
			waku.add("");
		}
		for (int i = 0; i < waku.size(); i++) {
			System.out.println(waku.get(i));
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String strNum = "";
		ArrayList<String> waku = new ArrayList<String>();
		while (true) {
			strNum = br.readLine();
			if ("0 0".equals(strNum)) {
				break;
			}
			for (int i = 0; i < Integer.parseInt(strNum.split(" ")[0]); i++) {
				String line = "";
				if (i == 0 || i == (Integer.parseInt(strNum.split(" ")[0]) - 1)) {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						line += "#";
					}
				} else {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						if (j == 0 || j == (Integer.parseInt(strNum.split(" ")[1]) - 1)) {
							line += "#";
						} else {
							line += ".";
						}
					}
				}
				waku.add(line);
			}
			waku.add("");
		}
		for (int i = 0; i < waku.size(); i++) {
			System.out.println(waku.get(i));
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String strNum = ""; strNum "" ArrayList<String> waku = new ArrayList<String>(); waku new ArrayList<String>() while (true) {
			strNum = br.readLine();
			if ("0 0".equals(strNum)) {
				break;
			}
			for (int i = 0; i < Integer.parseInt(strNum.split(" ")[0]); i++) {
				String line = "";
				if (i == 0 || i == (Integer.parseInt(strNum.split(" ")[0]) - 1)) {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						line += "#";
					}
				} else {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						if (j == 0 || j == (Integer.parseInt(strNum.split(" ")[1]) - 1)) {
							line += "#";
						} else {
							line += ".";
						}
					}
				}
				waku.add(line);
			}
			waku.add("");
		} true {
			strNum = br.readLine();
			if ("0 0".equals(strNum)) {
				break;
			}
			for (int i = 0; i < Integer.parseInt(strNum.split(" ")[0]); i++) {
				String line = "";
				if (i == 0 || i == (Integer.parseInt(strNum.split(" ")[0]) - 1)) {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						line += "#";
					}
				} else {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						if (j == 0 || j == (Integer.parseInt(strNum.split(" ")[1]) - 1)) {
							line += "#";
						} else {
							line += ".";
						}
					}
				}
				waku.add(line);
			}
			waku.add("");
		} strNum = br.readLine() strNum br.readLine() br.readLine br if ("0 0".equals(strNum)) {
				break;
			} "0 0".equals(strNum) "0 0".equals "0 0" strNum {
				break;
			} break; for (int i = 0; i < Integer.parseInt(strNum.split(" ")[0]); i++) {
				String line = "";
				if (i == 0 || i == (Integer.parseInt(strNum.split(" ")[0]) - 1)) {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						line += "#";
					}
				} else {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						if (j == 0 || j == (Integer.parseInt(strNum.split(" ")[1]) - 1)) {
							line += "#";
						} else {
							line += ".";
						}
					}
				}
				waku.add(line);
			} int i = 0; int i = 0; i 0 i < Integer.parseInt(strNum.split(" ")[0]) i Integer.parseInt(strNum.split(" ")[0]) Integer.parseInt Integer strNum.split(" ")[0] strNum.split(" ") strNum.split strNum " " 0 i++ i++ i {
				String line = "";
				if (i == 0 || i == (Integer.parseInt(strNum.split(" ")[0]) - 1)) {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						line += "#";
					}
				} else {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						if (j == 0 || j == (Integer.parseInt(strNum.split(" ")[1]) - 1)) {
							line += "#";
						} else {
							line += ".";
						}
					}
				}
				waku.add(line);
			} {
				String line = "";
				if (i == 0 || i == (Integer.parseInt(strNum.split(" ")[0]) - 1)) {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						line += "#";
					}
				} else {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						if (j == 0 || j == (Integer.parseInt(strNum.split(" ")[1]) - 1)) {
							line += "#";
						} else {
							line += ".";
						}
					}
				}
				waku.add(line);
			} String line = ""; line "" if (i == 0 || i == (Integer.parseInt(strNum.split(" ")[0]) - 1)) {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						line += "#";
					}
				} else {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						if (j == 0 || j == (Integer.parseInt(strNum.split(" ")[1]) - 1)) {
							line += "#";
						} else {
							line += ".";
						}
					}
				} i == 0 || i == (Integer.parseInt(strNum.split(" ")[0]) - 1) i == 0 i 0 i == (Integer.parseInt(strNum.split(" ")[0]) - 1) i (Integer.parseInt(strNum.split(" ")[0]) - 1) Integer.parseInt(strNum.split(" ")[0]) Integer.parseInt Integer strNum.split(" ")[0] strNum.split(" ") strNum.split strNum " " 0 1 {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						line += "#";
					}
				} for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						line += "#";
					} int j = 0; int j = 0; j 0 j < Integer.parseInt(strNum.split(" ")[1]) j Integer.parseInt(strNum.split(" ")[1]) Integer.parseInt Integer strNum.split(" ")[1] strNum.split(" ") strNum.split strNum " " 1 j++ j++ j {
						line += "#";
					} {
						line += "#";
					} line += "#" line "#" {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						if (j == 0 || j == (Integer.parseInt(strNum.split(" ")[1]) - 1)) {
							line += "#";
						} else {
							line += ".";
						}
					}
				} for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						if (j == 0 || j == (Integer.parseInt(strNum.split(" ")[1]) - 1)) {
							line += "#";
						} else {
							line += ".";
						}
					} int j = 0; int j = 0; j 0 j < Integer.parseInt(strNum.split(" ")[1]) j Integer.parseInt(strNum.split(" ")[1]) Integer.parseInt Integer strNum.split(" ")[1] strNum.split(" ") strNum.split strNum " " 1 j++ j++ j {
						if (j == 0 || j == (Integer.parseInt(strNum.split(" ")[1]) - 1)) {
							line += "#";
						} else {
							line += ".";
						}
					} {
						if (j == 0 || j == (Integer.parseInt(strNum.split(" ")[1]) - 1)) {
							line += "#";
						} else {
							line += ".";
						}
					} if (j == 0 || j == (Integer.parseInt(strNum.split(" ")[1]) - 1)) {
							line += "#";
						} else {
							line += ".";
						} j == 0 || j == (Integer.parseInt(strNum.split(" ")[1]) - 1) j == 0 j 0 j == (Integer.parseInt(strNum.split(" ")[1]) - 1) j (Integer.parseInt(strNum.split(" ")[1]) - 1) Integer.parseInt(strNum.split(" ")[1]) Integer.parseInt Integer strNum.split(" ")[1] strNum.split(" ") strNum.split strNum " " 1 1 {
							line += "#";
						} line += "#" line "#" {
							line += ".";
						} line += "." line "." waku.add(line) waku.add waku line waku.add("") waku.add waku "" for (int i = 0; i < waku.size(); i++) {
			System.out.println(waku.get(i));
		} int i = 0; int i = 0; i 0 i < waku.size() i waku.size() waku.size waku i++ i++ i {
			System.out.println(waku.get(i));
		} {
			System.out.println(waku.get(i));
		} System.out.println(waku.get(i)) System.out.println System.out System System.out waku.get(i) waku.get waku i String[] args args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String strNum = "";
		ArrayList<String> waku = new ArrayList<String>();
		while (true) {
			strNum = br.readLine();
			if ("0 0".equals(strNum)) {
				break;
			}
			for (int i = 0; i < Integer.parseInt(strNum.split(" ")[0]); i++) {
				String line = "";
				if (i == 0 || i == (Integer.parseInt(strNum.split(" ")[0]) - 1)) {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						line += "#";
					}
				} else {
					for (int j = 0; j < Integer.parseInt(strNum.split(" ")[1]); j++) {
						if (j == 0 || j == (Integer.parseInt(strNum.split(" ")[1]) - 1)) {
							line += "#";
						} else {
							line += ".";
						}
					}
				}
				waku.add(line);
			}
			waku.add("");
		}
		for (int i = 0; i < waku.size(); i++) {
			System.out.println(waku.get(i));
		}
	}

}