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

public class Main {
	public static void main(String[] arges) {
		Scanner sc = new Scanner(System.in);
		int i = 0;
		List<String> klist = new ArrayList<String>();
		while (i < 1) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}
		}
		
		for (String string : klist) {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int v = Integer.parseInt(k[0]);
			int v2 = Integer.parseInt(k[1]);
			for (int j = 0; j < v; j++) {

				int count = 0;
				if (j == 0 || j == v - 1) {
					while (count < v2) {
						System.out.print("#");
						count++;
					}

				} else {
					System.out.print("#");
					count++;
					while (count < v2 - 1) {
						System.out.print(".");
						count++;
					}
					System.out.print("#");
				}
				System.out.println("");

			}
		
			System.out.println("");
		}
	}
} 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[] arges) {
		Scanner sc = new Scanner(System.in);
		int i = 0;
		List<String> klist = new ArrayList<String>();
		while (i < 1) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}
		}
		
		for (String string : klist) {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int v = Integer.parseInt(k[0]);
			int v2 = Integer.parseInt(k[1]);
			for (int j = 0; j < v; j++) {

				int count = 0;
				if (j == 0 || j == v - 1) {
					while (count < v2) {
						System.out.print("#");
						count++;
					}

				} else {
					System.out.print("#");
					count++;
					while (count < v2 - 1) {
						System.out.print(".");
						count++;
					}
					System.out.print("#");
				}
				System.out.println("");

			}
		
			System.out.println("");
		}
	}
} Main public static void main(String[] arges) {
		Scanner sc = new Scanner(System.in);
		int i = 0;
		List<String> klist = new ArrayList<String>();
		while (i < 1) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}
		}
		
		for (String string : klist) {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int v = Integer.parseInt(k[0]);
			int v2 = Integer.parseInt(k[1]);
			for (int j = 0; j < v; j++) {

				int count = 0;
				if (j == 0 || j == v - 1) {
					while (count < v2) {
						System.out.print("#");
						count++;
					}

				} else {
					System.out.print("#");
					count++;
					while (count < v2 - 1) {
						System.out.print(".");
						count++;
					}
					System.out.print("#");
				}
				System.out.println("");

			}
		
			System.out.println("");
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int i = 0;
		List<String> klist = new ArrayList<String>();
		while (i < 1) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}
		}
		
		for (String string : klist) {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int v = Integer.parseInt(k[0]);
			int v2 = Integer.parseInt(k[1]);
			for (int j = 0; j < v; j++) {

				int count = 0;
				if (j == 0 || j == v - 1) {
					while (count < v2) {
						System.out.print("#");
						count++;
					}

				} else {
					System.out.print("#");
					count++;
					while (count < v2 - 1) {
						System.out.print(".");
						count++;
					}
					System.out.print("#");
				}
				System.out.println("");

			}
		
			System.out.println("");
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int i = 0; i 0 List<String> klist = new ArrayList<String>(); klist new ArrayList<String>() while (i < 1) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}
		} i < 1 i 1 {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}
		} String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc klist.add(line) klist.add klist line if (line.equals("0 0")) {
				break;
			} line.equals("0 0") line.equals line "0 0" {
				break;
			} break; for (String string : klist) {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int v = Integer.parseInt(k[0]);
			int v2 = Integer.parseInt(k[1]);
			for (int j = 0; j < v; j++) {

				int count = 0;
				if (j == 0 || j == v - 1) {
					while (count < v2) {
						System.out.print("#");
						count++;
					}

				} else {
					System.out.print("#");
					count++;
					while (count < v2 - 1) {
						System.out.print(".");
						count++;
					}
					System.out.print("#");
				}
				System.out.println("");

			}
		
			System.out.println("");
		} String string klist {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int v = Integer.parseInt(k[0]);
			int v2 = Integer.parseInt(k[1]);
			for (int j = 0; j < v; j++) {

				int count = 0;
				if (j == 0 || j == v - 1) {
					while (count < v2) {
						System.out.print("#");
						count++;
					}

				} else {
					System.out.print("#");
					count++;
					while (count < v2 - 1) {
						System.out.print(".");
						count++;
					}
					System.out.print("#");
				}
				System.out.println("");

			}
		
			System.out.println("");
		} {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int v = Integer.parseInt(k[0]);
			int v2 = Integer.parseInt(k[1]);
			for (int j = 0; j < v; j++) {

				int count = 0;
				if (j == 0 || j == v - 1) {
					while (count < v2) {
						System.out.print("#");
						count++;
					}

				} else {
					System.out.print("#");
					count++;
					while (count < v2 - 1) {
						System.out.print(".");
						count++;
					}
					System.out.print("#");
				}
				System.out.println("");

			}
		
			System.out.println("");
		} if (string.equals("0 0")) {
				break;
			} string.equals("0 0") string.equals string "0 0" {
				break;
			} break; String[] k = string.split(" "); k string.split(" ") string.split string " " int v = Integer.parseInt(k[0]); v Integer.parseInt(k[0]) Integer.parseInt Integer k[0] k 0 int v2 = Integer.parseInt(k[1]); v2 Integer.parseInt(k[1]) Integer.parseInt Integer k[1] k 1 for (int j = 0; j < v; j++) {

				int count = 0;
				if (j == 0 || j == v - 1) {
					while (count < v2) {
						System.out.print("#");
						count++;
					}

				} else {
					System.out.print("#");
					count++;
					while (count < v2 - 1) {
						System.out.print(".");
						count++;
					}
					System.out.print("#");
				}
				System.out.println("");

			} int j = 0; int j = 0; j 0 j < v j v j++ j++ j {

				int count = 0;
				if (j == 0 || j == v - 1) {
					while (count < v2) {
						System.out.print("#");
						count++;
					}

				} else {
					System.out.print("#");
					count++;
					while (count < v2 - 1) {
						System.out.print(".");
						count++;
					}
					System.out.print("#");
				}
				System.out.println("");

			} {

				int count = 0;
				if (j == 0 || j == v - 1) {
					while (count < v2) {
						System.out.print("#");
						count++;
					}

				} else {
					System.out.print("#");
					count++;
					while (count < v2 - 1) {
						System.out.print(".");
						count++;
					}
					System.out.print("#");
				}
				System.out.println("");

			} int count = 0; count 0 if (j == 0 || j == v - 1) {
					while (count < v2) {
						System.out.print("#");
						count++;
					}

				} else {
					System.out.print("#");
					count++;
					while (count < v2 - 1) {
						System.out.print(".");
						count++;
					}
					System.out.print("#");
				} j == 0 || j == v - 1 j == 0 j 0 j == v - 1 j v - 1 v 1 {
					while (count < v2) {
						System.out.print("#");
						count++;
					}

				} while (count < v2) {
						System.out.print("#");
						count++;
					} count < v2 count v2 {
						System.out.print("#");
						count++;
					} System.out.print("#") System.out.print System.out System System.out "#" count++ count {
					System.out.print("#");
					count++;
					while (count < v2 - 1) {
						System.out.print(".");
						count++;
					}
					System.out.print("#");
				} System.out.print("#") System.out.print System.out System System.out "#" count++ count while (count < v2 - 1) {
						System.out.print(".");
						count++;
					} count < v2 - 1 count v2 - 1 v2 1 {
						System.out.print(".");
						count++;
					} System.out.print(".") System.out.print System.out System System.out "." count++ count System.out.print("#") System.out.print System.out System System.out "#" System.out.println("") System.out.println System.out System System.out "" System.out.println("") System.out.println System.out System System.out "" String[] arges arges public class Main {
	public static void main(String[] arges) {
		Scanner sc = new Scanner(System.in);
		int i = 0;
		List<String> klist = new ArrayList<String>();
		while (i < 1) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}
		}
		
		for (String string : klist) {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int v = Integer.parseInt(k[0]);
			int v2 = Integer.parseInt(k[1]);
			for (int j = 0; j < v; j++) {

				int count = 0;
				if (j == 0 || j == v - 1) {
					while (count < v2) {
						System.out.print("#");
						count++;
					}

				} else {
					System.out.print("#");
					count++;
					while (count < v2 - 1) {
						System.out.print(".");
						count++;
					}
					System.out.print("#");
				}
				System.out.println("");

			}
		
			System.out.println("");
		}
	}
} public class Main {
	public static void main(String[] arges) {
		Scanner sc = new Scanner(System.in);
		int i = 0;
		List<String> klist = new ArrayList<String>();
		while (i < 1) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}
		}
		
		for (String string : klist) {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int v = Integer.parseInt(k[0]);
			int v2 = Integer.parseInt(k[1]);
			for (int j = 0; j < v; j++) {

				int count = 0;
				if (j == 0 || j == v - 1) {
					while (count < v2) {
						System.out.print("#");
						count++;
					}

				} else {
					System.out.print("#");
					count++;
					while (count < v2 - 1) {
						System.out.print(".");
						count++;
					}
					System.out.print("#");
				}
				System.out.println("");

			}
		
			System.out.println("");
		}
	}
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] arges) {
		Scanner sc = new Scanner(System.in);
		int i = 0;
		List<String> klist = new ArrayList<String>();
		while (i < 1) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}
		}
		
		for (String string : klist) {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int v = Integer.parseInt(k[0]);
			int v2 = Integer.parseInt(k[1]);
			for (int j = 0; j < v; j++) {

				int count = 0;
				if (j == 0 || j == v - 1) {
					while (count < v2) {
						System.out.print("#");
						count++;
					}

				} else {
					System.out.print("#");
					count++;
					while (count < v2 - 1) {
						System.out.print(".");
						count++;
					}
					System.out.print("#");
				}
				System.out.println("");

			}
		
			System.out.println("");
		}
	}
}