import java.text.*;
import java.math.*;
import java.util.*;

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

		while(true) {
			num[0] = scan.nextInt();
			num[1] = scan.nextInt();
			if(num[0] == 0) break;
			for(int i1 = 0; i1 < num[0];i1++) {
				for(int i2 = 0;i2 < num[1];i2++) {
					if(i1 == 0 | i1 == num[0]-1) {
						System.out.print("#");
					}else if(i2 == 0|i2 == num[1]-1) {
						System.out.print("#");
					}else System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
		
	}
} import java.text.*; text.* java import java.math.*; math.* java import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] num= new int[2];

		while(true) {
			num[0] = scan.nextInt();
			num[1] = scan.nextInt();
			if(num[0] == 0) break;
			for(int i1 = 0; i1 < num[0];i1++) {
				for(int i2 = 0;i2 < num[1];i2++) {
					if(i1 == 0 | i1 == num[0]-1) {
						System.out.print("#");
					}else if(i2 == 0|i2 == num[1]-1) {
						System.out.print("#");
					}else System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
		
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] num= new int[2];

		while(true) {
			num[0] = scan.nextInt();
			num[1] = scan.nextInt();
			if(num[0] == 0) break;
			for(int i1 = 0; i1 < num[0];i1++) {
				for(int i2 = 0;i2 < num[1];i2++) {
					if(i1 == 0 | i1 == num[0]-1) {
						System.out.print("#");
					}else if(i2 == 0|i2 == num[1]-1) {
						System.out.print("#");
					}else System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
		
	} main {
		Scanner scan = new Scanner(System.in);
		int[] num= new int[2];

		while(true) {
			num[0] = scan.nextInt();
			num[1] = scan.nextInt();
			if(num[0] == 0) break;
			for(int i1 = 0; i1 < num[0];i1++) {
				for(int i2 = 0;i2 < num[1];i2++) {
					if(i1 == 0 | i1 == num[0]-1) {
						System.out.print("#");
					}else if(i2 == 0|i2 == num[1]-1) {
						System.out.print("#");
					}else System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
		
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int[] num= new int[2]; num new int[2] 2 while(true) {
			num[0] = scan.nextInt();
			num[1] = scan.nextInt();
			if(num[0] == 0) break;
			for(int i1 = 0; i1 < num[0];i1++) {
				for(int i2 = 0;i2 < num[1];i2++) {
					if(i1 == 0 | i1 == num[0]-1) {
						System.out.print("#");
					}else if(i2 == 0|i2 == num[1]-1) {
						System.out.print("#");
					}else System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		} true {
			num[0] = scan.nextInt();
			num[1] = scan.nextInt();
			if(num[0] == 0) break;
			for(int i1 = 0; i1 < num[0];i1++) {
				for(int i2 = 0;i2 < num[1];i2++) {
					if(i1 == 0 | i1 == num[0]-1) {
						System.out.print("#");
					}else if(i2 == 0|i2 == num[1]-1) {
						System.out.print("#");
					}else System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		} num[0] = scan.nextInt() num[0] num 0 scan.nextInt() scan.nextInt scan num[1] = scan.nextInt() num[1] num 1 scan.nextInt() scan.nextInt scan if(num[0] == 0) break; num[0] == 0 num[0] num 0 0 break; for(int i1 = 0; i1 < num[0];i1++) {
				for(int i2 = 0;i2 < num[1];i2++) {
					if(i1 == 0 | i1 == num[0]-1) {
						System.out.print("#");
					}else if(i2 == 0|i2 == num[1]-1) {
						System.out.print("#");
					}else System.out.print(".");
				}
				System.out.println();
			} int i1 = 0; int i1 = 0; i1 0 i1 < num[0] i1 num[0] num 0 i1++ i1++ i1 {
				for(int i2 = 0;i2 < num[1];i2++) {
					if(i1 == 0 | i1 == num[0]-1) {
						System.out.print("#");
					}else if(i2 == 0|i2 == num[1]-1) {
						System.out.print("#");
					}else System.out.print(".");
				}
				System.out.println();
			} {
				for(int i2 = 0;i2 < num[1];i2++) {
					if(i1 == 0 | i1 == num[0]-1) {
						System.out.print("#");
					}else if(i2 == 0|i2 == num[1]-1) {
						System.out.print("#");
					}else System.out.print(".");
				}
				System.out.println();
			} for(int i2 = 0;i2 < num[1];i2++) {
					if(i1 == 0 | i1 == num[0]-1) {
						System.out.print("#");
					}else if(i2 == 0|i2 == num[1]-1) {
						System.out.print("#");
					}else System.out.print(".");
				} int i2 = 0; int i2 = 0; i2 0 i2 < num[1] i2 num[1] num 1 i2++ i2++ i2 {
					if(i1 == 0 | i1 == num[0]-1) {
						System.out.print("#");
					}else if(i2 == 0|i2 == num[1]-1) {
						System.out.print("#");
					}else System.out.print(".");
				} {
					if(i1 == 0 | i1 == num[0]-1) {
						System.out.print("#");
					}else if(i2 == 0|i2 == num[1]-1) {
						System.out.print("#");
					}else System.out.print(".");
				} if(i1 == 0 | i1 == num[0]-1) {
						System.out.print("#");
					}else if(i2 == 0|i2 == num[1]-1) {
						System.out.print("#");
					}else System.out.print("."); i1 == 0 | i1 == num[0]-1 i1 == 0 i1 0 i1 == num[0]-1 i1 num[0]-1 num[0] num 0 1 {
						System.out.print("#");
					} System.out.print("#") System.out.print System.out System System.out "#" if(i2 == 0|i2 == num[1]-1) {
						System.out.print("#");
					}else System.out.print("."); i2 == 0|i2 == num[1]-1 i2 == 0 i2 0 i2 == num[1]-1 i2 num[1]-1 num[1] num 1 1 {
						System.out.print("#");
					} System.out.print("#") System.out.print System.out System System.out "#" 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) {
		Scanner scan = new Scanner(System.in);
		int[] num= new int[2];

		while(true) {
			num[0] = scan.nextInt();
			num[1] = scan.nextInt();
			if(num[0] == 0) break;
			for(int i1 = 0; i1 < num[0];i1++) {
				for(int i2 = 0;i2 < num[1];i2++) {
					if(i1 == 0 | i1 == num[0]-1) {
						System.out.print("#");
					}else if(i2 == 0|i2 == num[1]-1) {
						System.out.print("#");
					}else System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
		
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] num= new int[2];

		while(true) {
			num[0] = scan.nextInt();
			num[1] = scan.nextInt();
			if(num[0] == 0) break;
			for(int i1 = 0; i1 < num[0];i1++) {
				for(int i2 = 0;i2 < num[1];i2++) {
					if(i1 == 0 | i1 == num[0]-1) {
						System.out.print("#");
					}else if(i2 == 0|i2 == num[1]-1) {
						System.out.print("#");
					}else System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
		
	}
} Main
import java.text.*;
import java.math.*;
import java.util.*;

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

		while(true) {
			num[0] = scan.nextInt();
			num[1] = scan.nextInt();
			if(num[0] == 0) break;
			for(int i1 = 0; i1 < num[0];i1++) {
				for(int i2 = 0;i2 < num[1];i2++) {
					if(i1 == 0 | i1 == num[0]-1) {
						System.out.print("#");
					}else if(i2 == 0|i2 == num[1]-1) {
						System.out.print("#");
					}else System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
		
	}
}