import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(new BufferedInputStream(System.in));
		List<String> output = new ArrayList<String>();
		while (scan.hasNext()) {
			String input = scan.nextLine();
			String[] in = input.split(" ");
			int H = Integer.parseInt(in[0]);
			int W = Integer.parseInt(in[1]);
			if (H == 0 && W == 0) {
				break;
			} else {
				if (H >= 1 && H <= 300 && W >= 1 && W <= 300) {
					for (int i = 1; i <= H; i++) {
						String result = "";
						for (int j = 1; j <= W; j++) {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						}
						output.add(result);
					}
					output.add("");
				}
			}
		}
		for (String out : output) {
			System.out.println(out);
		}
	}
} import java.io.BufferedInputStream; BufferedInputStream java.io import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(new BufferedInputStream(System.in));
		List<String> output = new ArrayList<String>();
		while (scan.hasNext()) {
			String input = scan.nextLine();
			String[] in = input.split(" ");
			int H = Integer.parseInt(in[0]);
			int W = Integer.parseInt(in[1]);
			if (H == 0 && W == 0) {
				break;
			} else {
				if (H >= 1 && H <= 300 && W >= 1 && W <= 300) {
					for (int i = 1; i <= H; i++) {
						String result = "";
						for (int j = 1; j <= W; j++) {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						}
						output.add(result);
					}
					output.add("");
				}
			}
		}
		for (String out : output) {
			System.out.println(out);
		}
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(new BufferedInputStream(System.in));
		List<String> output = new ArrayList<String>();
		while (scan.hasNext()) {
			String input = scan.nextLine();
			String[] in = input.split(" ");
			int H = Integer.parseInt(in[0]);
			int W = Integer.parseInt(in[1]);
			if (H == 0 && W == 0) {
				break;
			} else {
				if (H >= 1 && H <= 300 && W >= 1 && W <= 300) {
					for (int i = 1; i <= H; i++) {
						String result = "";
						for (int j = 1; j <= W; j++) {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						}
						output.add(result);
					}
					output.add("");
				}
			}
		}
		for (String out : output) {
			System.out.println(out);
		}
	} main {
		Scanner scan = new Scanner(new BufferedInputStream(System.in));
		List<String> output = new ArrayList<String>();
		while (scan.hasNext()) {
			String input = scan.nextLine();
			String[] in = input.split(" ");
			int H = Integer.parseInt(in[0]);
			int W = Integer.parseInt(in[1]);
			if (H == 0 && W == 0) {
				break;
			} else {
				if (H >= 1 && H <= 300 && W >= 1 && W <= 300) {
					for (int i = 1; i <= H; i++) {
						String result = "";
						for (int j = 1; j <= W; j++) {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						}
						output.add(result);
					}
					output.add("");
				}
			}
		}
		for (String out : output) {
			System.out.println(out);
		}
	} Scanner scan = new Scanner(new BufferedInputStream(System.in)); scan new Scanner(new BufferedInputStream(System.in)) List<String> output = new ArrayList<String>(); output new ArrayList<String>() while (scan.hasNext()) {
			String input = scan.nextLine();
			String[] in = input.split(" ");
			int H = Integer.parseInt(in[0]);
			int W = Integer.parseInt(in[1]);
			if (H == 0 && W == 0) {
				break;
			} else {
				if (H >= 1 && H <= 300 && W >= 1 && W <= 300) {
					for (int i = 1; i <= H; i++) {
						String result = "";
						for (int j = 1; j <= W; j++) {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						}
						output.add(result);
					}
					output.add("");
				}
			}
		} scan.hasNext() scan.hasNext scan {
			String input = scan.nextLine();
			String[] in = input.split(" ");
			int H = Integer.parseInt(in[0]);
			int W = Integer.parseInt(in[1]);
			if (H == 0 && W == 0) {
				break;
			} else {
				if (H >= 1 && H <= 300 && W >= 1 && W <= 300) {
					for (int i = 1; i <= H; i++) {
						String result = "";
						for (int j = 1; j <= W; j++) {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						}
						output.add(result);
					}
					output.add("");
				}
			}
		} String input = scan.nextLine(); input scan.nextLine() scan.nextLine scan String[] in = input.split(" "); in input.split(" ") input.split input " " int H = Integer.parseInt(in[0]); H Integer.parseInt(in[0]) Integer.parseInt Integer in[0] in 0 int W = Integer.parseInt(in[1]); W Integer.parseInt(in[1]) Integer.parseInt Integer in[1] in 1 if (H == 0 && W == 0) {
				break;
			} else {
				if (H >= 1 && H <= 300 && W >= 1 && W <= 300) {
					for (int i = 1; i <= H; i++) {
						String result = "";
						for (int j = 1; j <= W; j++) {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						}
						output.add(result);
					}
					output.add("");
				}
			} H == 0 && W == 0 H == 0 H 0 W == 0 W 0 {
				break;
			} break; {
				if (H >= 1 && H <= 300 && W >= 1 && W <= 300) {
					for (int i = 1; i <= H; i++) {
						String result = "";
						for (int j = 1; j <= W; j++) {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						}
						output.add(result);
					}
					output.add("");
				}
			} if (H >= 1 && H <= 300 && W >= 1 && W <= 300) {
					for (int i = 1; i <= H; i++) {
						String result = "";
						for (int j = 1; j <= W; j++) {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						}
						output.add(result);
					}
					output.add("");
				} H >= 1 && H <= 300 && W >= 1 && W <= 300 W >= 1 H >= 1 && H <= 300 && W >= 1 && W <= 300 H >= 1 H 1 H <= 300 H 300 W >= 1 W 1 W <= 300 W 300 {
					for (int i = 1; i <= H; i++) {
						String result = "";
						for (int j = 1; j <= W; j++) {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						}
						output.add(result);
					}
					output.add("");
				} for (int i = 1; i <= H; i++) {
						String result = "";
						for (int j = 1; j <= W; j++) {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						}
						output.add(result);
					} int i = 1; int i = 1; i 1 i <= H i H i++ i++ i {
						String result = "";
						for (int j = 1; j <= W; j++) {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						}
						output.add(result);
					} {
						String result = "";
						for (int j = 1; j <= W; j++) {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						}
						output.add(result);
					} String result = ""; result "" for (int j = 1; j <= W; j++) {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						} int j = 1; int j = 1; j 1 j <= W j W j++ j++ j {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						} {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						} if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							} i == 1 || i == H i == 1 i 1 i == H i H {
								result += "#";
							} result += "#" result "#" {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							} if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								} j == 1 || j == W j == 1 j 1 j == W j W {
									result += "#";
								} result += "#" result "#" {
									result += ".";
								} result += "." result "." output.add(result) output.add output result output.add("") output.add output "" for (String out : output) {
			System.out.println(out);
		} String out output {
			System.out.println(out);
		} {
			System.out.println(out);
		} System.out.println(out) System.out.println System.out System System.out out String[] args args public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(new BufferedInputStream(System.in));
		List<String> output = new ArrayList<String>();
		while (scan.hasNext()) {
			String input = scan.nextLine();
			String[] in = input.split(" ");
			int H = Integer.parseInt(in[0]);
			int W = Integer.parseInt(in[1]);
			if (H == 0 && W == 0) {
				break;
			} else {
				if (H >= 1 && H <= 300 && W >= 1 && W <= 300) {
					for (int i = 1; i <= H; i++) {
						String result = "";
						for (int j = 1; j <= W; j++) {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						}
						output.add(result);
					}
					output.add("");
				}
			}
		}
		for (String out : output) {
			System.out.println(out);
		}
	}
} public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(new BufferedInputStream(System.in));
		List<String> output = new ArrayList<String>();
		while (scan.hasNext()) {
			String input = scan.nextLine();
			String[] in = input.split(" ");
			int H = Integer.parseInt(in[0]);
			int W = Integer.parseInt(in[1]);
			if (H == 0 && W == 0) {
				break;
			} else {
				if (H >= 1 && H <= 300 && W >= 1 && W <= 300) {
					for (int i = 1; i <= H; i++) {
						String result = "";
						for (int j = 1; j <= W; j++) {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						}
						output.add(result);
					}
					output.add("");
				}
			}
		}
		for (String out : output) {
			System.out.println(out);
		}
	}
} Main
import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(new BufferedInputStream(System.in));
		List<String> output = new ArrayList<String>();
		while (scan.hasNext()) {
			String input = scan.nextLine();
			String[] in = input.split(" ");
			int H = Integer.parseInt(in[0]);
			int W = Integer.parseInt(in[1]);
			if (H == 0 && W == 0) {
				break;
			} else {
				if (H >= 1 && H <= 300 && W >= 1 && W <= 300) {
					for (int i = 1; i <= H; i++) {
						String result = "";
						for (int j = 1; j <= W; j++) {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						}
						output.add(result);
					}
					output.add("");
				}
			}
		}
		for (String out : output) {
			System.out.println(out);
		}
	}
}