import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		LinkedList<Integer> ll = new LinkedList<>();
		
		int H = 999;
		int W = 999;
		
		int cnt = 0;
		
		//?????????????´?
		while(H != 0 || W != 0) {
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0) {
				break;
			} else {
				ll.add(H);
				ll.add(W);
				cnt+=2;
			}
		}
		
		int k = 0;
		while(k < cnt) {
			int j = 0;
			while(j < ll.get(k)) {
				int i = 0;
				while(i < ll.get(k+1)) {
					if(j == 0 || j == ll.get(k) - 1
					 ||i == 0 || i == ll.get(k+1) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
					i++;
				}
				System.out.println();
				j++;
			}
			System.out.println();
			k+=2;
		}
		
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		LinkedList<Integer> ll = new LinkedList<>();
		
		int H = 999;
		int W = 999;
		
		int cnt = 0;
		
		//?????????????´?
		while(H != 0 || W != 0) {
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0) {
				break;
			} else {
				ll.add(H);
				ll.add(W);
				cnt+=2;
			}
		}
		
		int k = 0;
		while(k < cnt) {
			int j = 0;
			while(j < ll.get(k)) {
				int i = 0;
				while(i < ll.get(k+1)) {
					if(j == 0 || j == ll.get(k) - 1
					 ||i == 0 || i == ll.get(k+1) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
					i++;
				}
				System.out.println();
				j++;
			}
			System.out.println();
			k+=2;
		}
		
	}
} Main public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		LinkedList<Integer> ll = new LinkedList<>();
		
		int H = 999;
		int W = 999;
		
		int cnt = 0;
		
		//?????????????´?
		while(H != 0 || W != 0) {
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0) {
				break;
			} else {
				ll.add(H);
				ll.add(W);
				cnt+=2;
			}
		}
		
		int k = 0;
		while(k < cnt) {
			int j = 0;
			while(j < ll.get(k)) {
				int i = 0;
				while(i < ll.get(k+1)) {
					if(j == 0 || j == ll.get(k) - 1
					 ||i == 0 || i == ll.get(k+1) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
					i++;
				}
				System.out.println();
				j++;
			}
			System.out.println();
			k+=2;
		}
		
	} main {
		
		Scanner sc = new Scanner(System.in);
		LinkedList<Integer> ll = new LinkedList<>();
		
		int H = 999;
		int W = 999;
		
		int cnt = 0;
		
		//?????????????´?
		while(H != 0 || W != 0) {
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0) {
				break;
			} else {
				ll.add(H);
				ll.add(W);
				cnt+=2;
			}
		}
		
		int k = 0;
		while(k < cnt) {
			int j = 0;
			while(j < ll.get(k)) {
				int i = 0;
				while(i < ll.get(k+1)) {
					if(j == 0 || j == ll.get(k) - 1
					 ||i == 0 || i == ll.get(k+1) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
					i++;
				}
				System.out.println();
				j++;
			}
			System.out.println();
			k+=2;
		}
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) LinkedList<Integer> ll = new LinkedList<>(); ll new LinkedList<>() int H = 999; H 999 int W = 999; W 999 int cnt = 0; cnt 0 while(H != 0 || W != 0) {
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0) {
				break;
			} else {
				ll.add(H);
				ll.add(W);
				cnt+=2;
			}
		} H != 0 || W != 0 H != 0 H 0 W != 0 W 0 {
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0) {
				break;
			} else {
				ll.add(H);
				ll.add(W);
				cnt+=2;
			}
		} H = sc.nextInt() H sc.nextInt() sc.nextInt sc W = sc.nextInt() W sc.nextInt() sc.nextInt sc if(H == 0 && W == 0) {
				break;
			} else {
				ll.add(H);
				ll.add(W);
				cnt+=2;
			} H == 0 && W == 0 H == 0 H 0 W == 0 W 0 {
				break;
			} break; {
				ll.add(H);
				ll.add(W);
				cnt+=2;
			} ll.add(H) ll.add ll H ll.add(W) ll.add ll W cnt+=2 cnt 2 int k = 0; k 0 while(k < cnt) {
			int j = 0;
			while(j < ll.get(k)) {
				int i = 0;
				while(i < ll.get(k+1)) {
					if(j == 0 || j == ll.get(k) - 1
					 ||i == 0 || i == ll.get(k+1) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
					i++;
				}
				System.out.println();
				j++;
			}
			System.out.println();
			k+=2;
		} k < cnt k cnt {
			int j = 0;
			while(j < ll.get(k)) {
				int i = 0;
				while(i < ll.get(k+1)) {
					if(j == 0 || j == ll.get(k) - 1
					 ||i == 0 || i == ll.get(k+1) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
					i++;
				}
				System.out.println();
				j++;
			}
			System.out.println();
			k+=2;
		} int j = 0; j 0 while(j < ll.get(k)) {
				int i = 0;
				while(i < ll.get(k+1)) {
					if(j == 0 || j == ll.get(k) - 1
					 ||i == 0 || i == ll.get(k+1) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
					i++;
				}
				System.out.println();
				j++;
			} j < ll.get(k) j ll.get(k) ll.get ll k {
				int i = 0;
				while(i < ll.get(k+1)) {
					if(j == 0 || j == ll.get(k) - 1
					 ||i == 0 || i == ll.get(k+1) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
					i++;
				}
				System.out.println();
				j++;
			} int i = 0; i 0 while(i < ll.get(k+1)) {
					if(j == 0 || j == ll.get(k) - 1
					 ||i == 0 || i == ll.get(k+1) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
					i++;
				} i < ll.get(k+1) i ll.get(k+1) ll.get ll k+1 k 1 {
					if(j == 0 || j == ll.get(k) - 1
					 ||i == 0 || i == ll.get(k+1) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
					i++;
				} if(j == 0 || j == ll.get(k) - 1
					 ||i == 0 || i == ll.get(k+1) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					} j == 0 || j == ll.get(k) - 1
					 ||i == 0 || i == ll.get(k+1) - 1 i == 0 j == 0 || j == ll.get(k) - 1
					 ||i == 0 || i == ll.get(k+1) - 1 j == 0 j 0 j == ll.get(k) - 1 j ll.get(k) - 1 ll.get(k) ll.get ll k 1 i == 0 i 0 i == ll.get(k+1) - 1 i ll.get(k+1) - 1 ll.get(k+1) ll.get ll k+1 k 1 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 "." i++ i System.out.println() System.out.println System.out System System.out j++ j System.out.println() System.out.println System.out System System.out k+=2 k 2 String[] args args public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		LinkedList<Integer> ll = new LinkedList<>();
		
		int H = 999;
		int W = 999;
		
		int cnt = 0;
		
		//?????????????´?
		while(H != 0 || W != 0) {
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0) {
				break;
			} else {
				ll.add(H);
				ll.add(W);
				cnt+=2;
			}
		}
		
		int k = 0;
		while(k < cnt) {
			int j = 0;
			while(j < ll.get(k)) {
				int i = 0;
				while(i < ll.get(k+1)) {
					if(j == 0 || j == ll.get(k) - 1
					 ||i == 0 || i == ll.get(k+1) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
					i++;
				}
				System.out.println();
				j++;
			}
			System.out.println();
			k+=2;
		}
		
	}
} public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		LinkedList<Integer> ll = new LinkedList<>();
		
		int H = 999;
		int W = 999;
		
		int cnt = 0;
		
		//?????????????´?
		while(H != 0 || W != 0) {
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0) {
				break;
			} else {
				ll.add(H);
				ll.add(W);
				cnt+=2;
			}
		}
		
		int k = 0;
		while(k < cnt) {
			int j = 0;
			while(j < ll.get(k)) {
				int i = 0;
				while(i < ll.get(k+1)) {
					if(j == 0 || j == ll.get(k) - 1
					 ||i == 0 || i == ll.get(k+1) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
					i++;
				}
				System.out.println();
				j++;
			}
			System.out.println();
			k+=2;
		}
		
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		LinkedList<Integer> ll = new LinkedList<>();
		
		int H = 999;
		int W = 999;
		
		int cnt = 0;
		
		//?????????????´?
		while(H != 0 || W != 0) {
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0) {
				break;
			} else {
				ll.add(H);
				ll.add(W);
				cnt+=2;
			}
		}
		
		int k = 0;
		while(k < cnt) {
			int j = 0;
			while(j < ll.get(k)) {
				int i = 0;
				while(i < ll.get(k+1)) {
					if(j == 0 || j == ll.get(k) - 1
					 ||i == 0 || i == ll.get(k+1) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
					i++;
				}
				System.out.println();
				j++;
			}
			System.out.println();
			k+=2;
		}
		
	}
}