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

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()) != null) {
				if (x.equals("0 0")) break;
				
				String[] values = x.split(" ");
	
				int a = Integer.parseInt(values[0]);
				int b = Integer.parseInt(values[1]);
				
				for (int i = 0; i < a; i++) {
					for (int j = 0; j < b; j++) {
						if ((i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1))) {
							System.out.print('#');
						} else {
							System.out.print('.');
						}
					}
					System.out.println();
				}
				System.out.println();
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			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 in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()) != null) {
				if (x.equals("0 0")) break;
				
				String[] values = x.split(" ");
	
				int a = Integer.parseInt(values[0]);
				int b = Integer.parseInt(values[1]);
				
				for (int i = 0; i < a; i++) {
					for (int j = 0; j < b; j++) {
						if ((i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1))) {
							System.out.print('#');
						} else {
							System.out.print('.');
						}
					}
					System.out.println();
				}
				System.out.println();
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} Main public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()) != null) {
				if (x.equals("0 0")) break;
				
				String[] values = x.split(" ");
	
				int a = Integer.parseInt(values[0]);
				int b = Integer.parseInt(values[1]);
				
				for (int i = 0; i < a; i++) {
					for (int j = 0; j < b; j++) {
						if ((i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1))) {
							System.out.print('#');
						} else {
							System.out.print('.');
						}
					}
					System.out.println();
				}
				System.out.println();
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	} main {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()) != null) {
				if (x.equals("0 0")) break;
				
				String[] values = x.split(" ");
	
				int a = Integer.parseInt(values[0]);
				int b = Integer.parseInt(values[1]);
				
				for (int i = 0; i < a; i++) {
					for (int j = 0; j < b; j++) {
						if ((i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1))) {
							System.out.print('#');
						} else {
							System.out.print('.');
						}
					}
					System.out.println();
				}
				System.out.println();
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) String x = ""; x "" try {
			while ((x = in.readLine()) != null) {
				if (x.equals("0 0")) break;
				
				String[] values = x.split(" ");
	
				int a = Integer.parseInt(values[0]);
				int b = Integer.parseInt(values[1]);
				
				for (int i = 0; i < a; i++) {
					for (int j = 0; j < b; j++) {
						if ((i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1))) {
							System.out.print('#');
						} else {
							System.out.print('.');
						}
					}
					System.out.println();
				}
				System.out.println();
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} NumberFormatException e {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} IOException e {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			while ((x = in.readLine()) != null) {
				if (x.equals("0 0")) break;
				
				String[] values = x.split(" ");
	
				int a = Integer.parseInt(values[0]);
				int b = Integer.parseInt(values[1]);
				
				for (int i = 0; i < a; i++) {
					for (int j = 0; j < b; j++) {
						if ((i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1))) {
							System.out.print('#');
						} else {
							System.out.print('.');
						}
					}
					System.out.println();
				}
				System.out.println();
			}
		} while ((x = in.readLine()) != null) {
				if (x.equals("0 0")) break;
				
				String[] values = x.split(" ");
	
				int a = Integer.parseInt(values[0]);
				int b = Integer.parseInt(values[1]);
				
				for (int i = 0; i < a; i++) {
					for (int j = 0; j < b; j++) {
						if ((i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1))) {
							System.out.print('#');
						} else {
							System.out.print('.');
						}
					}
					System.out.println();
				}
				System.out.println();
			} (x = in.readLine()) != null (x = in.readLine()) x in.readLine() in.readLine in null {
				if (x.equals("0 0")) break;
				
				String[] values = x.split(" ");
	
				int a = Integer.parseInt(values[0]);
				int b = Integer.parseInt(values[1]);
				
				for (int i = 0; i < a; i++) {
					for (int j = 0; j < b; j++) {
						if ((i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1))) {
							System.out.print('#');
						} else {
							System.out.print('.');
						}
					}
					System.out.println();
				}
				System.out.println();
			} if (x.equals("0 0")) break; x.equals("0 0") x.equals x "0 0" break; String[] values = x.split(" "); values x.split(" ") x.split x " " int a = Integer.parseInt(values[0]); a Integer.parseInt(values[0]) Integer.parseInt Integer values[0] values 0 int b = Integer.parseInt(values[1]); b Integer.parseInt(values[1]) Integer.parseInt Integer values[1] values 1 for (int i = 0; i < a; i++) {
					for (int j = 0; j < b; j++) {
						if ((i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1))) {
							System.out.print('#');
						} else {
							System.out.print('.');
						}
					}
					System.out.println();
				} int i = 0; int i = 0; i 0 i < a i a i++ i++ i {
					for (int j = 0; j < b; j++) {
						if ((i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1))) {
							System.out.print('#');
						} else {
							System.out.print('.');
						}
					}
					System.out.println();
				} {
					for (int j = 0; j < b; j++) {
						if ((i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1))) {
							System.out.print('#');
						} else {
							System.out.print('.');
						}
					}
					System.out.println();
				} for (int j = 0; j < b; j++) {
						if ((i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1))) {
							System.out.print('#');
						} else {
							System.out.print('.');
						}
					} int j = 0; int j = 0; j 0 j < b j b j++ j++ j {
						if ((i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1))) {
							System.out.print('#');
						} else {
							System.out.print('.');
						}
					} {
						if ((i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1))) {
							System.out.print('#');
						} else {
							System.out.print('.');
						}
					} if ((i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1))) {
							System.out.print('#');
						} else {
							System.out.print('.');
						} (i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1)) (i == (a - 1)) (i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1)) (i == 0) i 0 (j == 0) j 0 (i == (a - 1)) i (a - 1) a 1 (j == (b - 1)) j (b - 1) b 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 System.out.println() System.out.println System.out System System.out String[] args args public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()) != null) {
				if (x.equals("0 0")) break;
				
				String[] values = x.split(" ");
	
				int a = Integer.parseInt(values[0]);
				int b = Integer.parseInt(values[1]);
				
				for (int i = 0; i < a; i++) {
					for (int j = 0; j < b; j++) {
						if ((i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1))) {
							System.out.print('#');
						} else {
							System.out.print('.');
						}
					}
					System.out.println();
				}
				System.out.println();
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()) != null) {
				if (x.equals("0 0")) break;
				
				String[] values = x.split(" ");
	
				int a = Integer.parseInt(values[0]);
				int b = Integer.parseInt(values[1]);
				
				for (int i = 0; i < a; i++) {
					for (int j = 0; j < b; j++) {
						if ((i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1))) {
							System.out.print('#');
						} else {
							System.out.print('.');
						}
					}
					System.out.println();
				}
				System.out.println();
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			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 in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()) != null) {
				if (x.equals("0 0")) break;
				
				String[] values = x.split(" ");
	
				int a = Integer.parseInt(values[0]);
				int b = Integer.parseInt(values[1]);
				
				for (int i = 0; i < a; i++) {
					for (int j = 0; j < b; j++) {
						if ((i == 0) || (j == 0) || (i == (a - 1)) || (j == (b - 1))) {
							System.out.print('#');
						} else {
							System.out.print('.');
						}
					}
					System.out.println();
				}
				System.out.println();
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}