import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String[] lines = sc.nextLine().split(" ");
			int height = Integer.parseInt(lines[0]);
			int width = Integer.parseInt(lines[1]);

			if(height == 0 && width == 0) {
				break;
			} else {
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println();
				//height??????????¨?????????¨?????????
				for(int i = 1;i < height - 1;i++) {
					for(int j = 0;j < width;j++) {
						if(j == 0 || j == width - 1) {
						System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					System.out.println();
				}
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println("\n");
			}

		}
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String[] lines = sc.nextLine().split(" ");
			int height = Integer.parseInt(lines[0]);
			int width = Integer.parseInt(lines[1]);

			if(height == 0 && width == 0) {
				break;
			} else {
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println();
				//height??????????¨?????????¨?????????
				for(int i = 1;i < height - 1;i++) {
					for(int j = 0;j < width;j++) {
						if(j == 0 || j == width - 1) {
						System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					System.out.println();
				}
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println("\n");
			}

		}
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String[] lines = sc.nextLine().split(" ");
			int height = Integer.parseInt(lines[0]);
			int width = Integer.parseInt(lines[1]);

			if(height == 0 && width == 0) {
				break;
			} else {
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println();
				//height??????????¨?????????¨?????????
				for(int i = 1;i < height - 1;i++) {
					for(int j = 0;j < width;j++) {
						if(j == 0 || j == width - 1) {
						System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					System.out.println();
				}
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println("\n");
			}

		}
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String[] lines = sc.nextLine().split(" ");
			int height = Integer.parseInt(lines[0]);
			int width = Integer.parseInt(lines[1]);

			if(height == 0 && width == 0) {
				break;
			} else {
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println();
				//height??????????¨?????????¨?????????
				for(int i = 1;i < height - 1;i++) {
					for(int j = 0;j < width;j++) {
						if(j == 0 || j == width - 1) {
						System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					System.out.println();
				}
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println("\n");
			}

		}
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
			String[] lines = sc.nextLine().split(" ");
			int height = Integer.parseInt(lines[0]);
			int width = Integer.parseInt(lines[1]);

			if(height == 0 && width == 0) {
				break;
			} else {
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println();
				//height??????????¨?????????¨?????????
				for(int i = 1;i < height - 1;i++) {
					for(int j = 0;j < width;j++) {
						if(j == 0 || j == width - 1) {
						System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					System.out.println();
				}
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println("\n");
			}

		} true {
			String[] lines = sc.nextLine().split(" ");
			int height = Integer.parseInt(lines[0]);
			int width = Integer.parseInt(lines[1]);

			if(height == 0 && width == 0) {
				break;
			} else {
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println();
				//height??????????¨?????????¨?????????
				for(int i = 1;i < height - 1;i++) {
					for(int j = 0;j < width;j++) {
						if(j == 0 || j == width - 1) {
						System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					System.out.println();
				}
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println("\n");
			}

		} String[] lines = sc.nextLine().split(" "); lines sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int height = Integer.parseInt(lines[0]); height Integer.parseInt(lines[0]) Integer.parseInt Integer lines[0] lines 0 int width = Integer.parseInt(lines[1]); width Integer.parseInt(lines[1]) Integer.parseInt Integer lines[1] lines 1 if(height == 0 && width == 0) {
				break;
			} else {
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println();
				//height??????????¨?????????¨?????????
				for(int i = 1;i < height - 1;i++) {
					for(int j = 0;j < width;j++) {
						if(j == 0 || j == width - 1) {
						System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					System.out.println();
				}
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println("\n");
			} height == 0 && width == 0 height == 0 height 0 width == 0 width 0 {
				break;
			} break; {
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println();
				//height??????????¨?????????¨?????????
				for(int i = 1;i < height - 1;i++) {
					for(int j = 0;j < width;j++) {
						if(j == 0 || j == width - 1) {
						System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					System.out.println();
				}
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println("\n");
			} for(int i = 0;i <width;i++) {
					System.out.print("#");
				} int i = 0; int i = 0; i 0 i <width i width i++ i++ i {
					System.out.print("#");
				} {
					System.out.print("#");
				} System.out.print("#") System.out.print System.out System System.out "#" System.out.println() System.out.println System.out System System.out for(int i = 1;i < height - 1;i++) {
					for(int j = 0;j < width;j++) {
						if(j == 0 || j == width - 1) {
						System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					System.out.println();
				} int i = 1; int i = 1; i 1 i < height - 1 i height - 1 height 1 i++ i++ i {
					for(int j = 0;j < width;j++) {
						if(j == 0 || j == width - 1) {
						System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					System.out.println();
				} {
					for(int j = 0;j < width;j++) {
						if(j == 0 || j == width - 1) {
						System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					System.out.println();
				} for(int j = 0;j < width;j++) {
						if(j == 0 || j == width - 1) {
						System.out.print("#");
						} else {
							System.out.print(".");
						}
					} int j = 0; int j = 0; j 0 j < width j width j++ j++ j {
						if(j == 0 || j == width - 1) {
						System.out.print("#");
						} else {
							System.out.print(".");
						}
					} {
						if(j == 0 || j == width - 1) {
						System.out.print("#");
						} else {
							System.out.print(".");
						}
					} if(j == 0 || j == width - 1) {
						System.out.print("#");
						} else {
							System.out.print(".");
						} j == 0 || j == width - 1 j == 0 j 0 j == width - 1 j width - 1 width 1 {
						System.out.print("#");
						} System.out.print("#") System.out.print System.out System System.out "#" {
							System.out.print(".");
						} System.out.print(".") System.out.print System.out System System.out "." System.out.println() System.out.println System.out System System.out for(int i = 0;i <width;i++) {
					System.out.print("#");
				} int i = 0; int i = 0; i 0 i <width i width i++ i++ i {
					System.out.print("#");
				} {
					System.out.print("#");
				} System.out.print("#") System.out.print System.out System System.out "#" System.out.println("\n") System.out.println System.out System System.out "\n" sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String[] lines = sc.nextLine().split(" ");
			int height = Integer.parseInt(lines[0]);
			int width = Integer.parseInt(lines[1]);

			if(height == 0 && width == 0) {
				break;
			} else {
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println();
				//height??????????¨?????????¨?????????
				for(int i = 1;i < height - 1;i++) {
					for(int j = 0;j < width;j++) {
						if(j == 0 || j == width - 1) {
						System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					System.out.println();
				}
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println("\n");
			}

		}
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String[] lines = sc.nextLine().split(" ");
			int height = Integer.parseInt(lines[0]);
			int width = Integer.parseInt(lines[1]);

			if(height == 0 && width == 0) {
				break;
			} else {
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println();
				//height??????????¨?????????¨?????????
				for(int i = 1;i < height - 1;i++) {
					for(int j = 0;j < width;j++) {
						if(j == 0 || j == width - 1) {
						System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					System.out.println();
				}
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println("\n");
			}

		}
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String[] lines = sc.nextLine().split(" ");
			int height = Integer.parseInt(lines[0]);
			int width = Integer.parseInt(lines[1]);

			if(height == 0 && width == 0) {
				break;
			} else {
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println();
				//height??????????¨?????????¨?????????
				for(int i = 1;i < height - 1;i++) {
					for(int j = 0;j < width;j++) {
						if(j == 0 || j == width - 1) {
						System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					System.out.println();
				}
				for(int i = 0;i <width;i++) {
					System.out.print("#");
				}
				System.out.println("\n");
			}

		}
		sc.close();
	}
}