import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		while(true){
			int h = Integer.parseInt(std.next());
			int w = Integer.parseInt(std.next());
			if(h!=0 && w!=0){
				String line = "";
				String line2 = "#";
				for(int m=1; m<=w; m++){
					line += "#";
					line2 += ".";
				}
				line2 = line2.substring(0, w-1)+"#";
				System.out.println(line);
				for(int n=2; n<=h-1; n++){
					System.out.println(line2);
				}
				System.out.println(line);
				System.out.println();
			}else break;
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		while(true){
			int h = Integer.parseInt(std.next());
			int w = Integer.parseInt(std.next());
			if(h!=0 && w!=0){
				String line = "";
				String line2 = "#";
				for(int m=1; m<=w; m++){
					line += "#";
					line2 += ".";
				}
				line2 = line2.substring(0, w-1)+"#";
				System.out.println(line);
				for(int n=2; n<=h-1; n++){
					System.out.println(line2);
				}
				System.out.println(line);
				System.out.println();
			}else break;
		}
	}
} Main public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		while(true){
			int h = Integer.parseInt(std.next());
			int w = Integer.parseInt(std.next());
			if(h!=0 && w!=0){
				String line = "";
				String line2 = "#";
				for(int m=1; m<=w; m++){
					line += "#";
					line2 += ".";
				}
				line2 = line2.substring(0, w-1)+"#";
				System.out.println(line);
				for(int n=2; n<=h-1; n++){
					System.out.println(line2);
				}
				System.out.println(line);
				System.out.println();
			}else break;
		}
	} main {
		Scanner std = new Scanner(System.in);
		while(true){
			int h = Integer.parseInt(std.next());
			int w = Integer.parseInt(std.next());
			if(h!=0 && w!=0){
				String line = "";
				String line2 = "#";
				for(int m=1; m<=w; m++){
					line += "#";
					line2 += ".";
				}
				line2 = line2.substring(0, w-1)+"#";
				System.out.println(line);
				for(int n=2; n<=h-1; n++){
					System.out.println(line2);
				}
				System.out.println(line);
				System.out.println();
			}else break;
		}
	} Scanner std = new Scanner(System.in); std new Scanner(System.in) while(true){
			int h = Integer.parseInt(std.next());
			int w = Integer.parseInt(std.next());
			if(h!=0 && w!=0){
				String line = "";
				String line2 = "#";
				for(int m=1; m<=w; m++){
					line += "#";
					line2 += ".";
				}
				line2 = line2.substring(0, w-1)+"#";
				System.out.println(line);
				for(int n=2; n<=h-1; n++){
					System.out.println(line2);
				}
				System.out.println(line);
				System.out.println();
			}else break;
		} true {
			int h = Integer.parseInt(std.next());
			int w = Integer.parseInt(std.next());
			if(h!=0 && w!=0){
				String line = "";
				String line2 = "#";
				for(int m=1; m<=w; m++){
					line += "#";
					line2 += ".";
				}
				line2 = line2.substring(0, w-1)+"#";
				System.out.println(line);
				for(int n=2; n<=h-1; n++){
					System.out.println(line2);
				}
				System.out.println(line);
				System.out.println();
			}else break;
		} int h = Integer.parseInt(std.next()); h Integer.parseInt(std.next()) Integer.parseInt Integer std.next() std.next std int w = Integer.parseInt(std.next()); w Integer.parseInt(std.next()) Integer.parseInt Integer std.next() std.next std if(h!=0 && w!=0){
				String line = "";
				String line2 = "#";
				for(int m=1; m<=w; m++){
					line += "#";
					line2 += ".";
				}
				line2 = line2.substring(0, w-1)+"#";
				System.out.println(line);
				for(int n=2; n<=h-1; n++){
					System.out.println(line2);
				}
				System.out.println(line);
				System.out.println();
			}else break; h!=0 && w!=0 h!=0 h 0 w!=0 w 0 {
				String line = "";
				String line2 = "#";
				for(int m=1; m<=w; m++){
					line += "#";
					line2 += ".";
				}
				line2 = line2.substring(0, w-1)+"#";
				System.out.println(line);
				for(int n=2; n<=h-1; n++){
					System.out.println(line2);
				}
				System.out.println(line);
				System.out.println();
			} String line = ""; line "" String line2 = "#"; line2 "#" for(int m=1; m<=w; m++){
					line += "#";
					line2 += ".";
				} int m=1; int m=1; m 1 m<=w m w m++ m++ m {
					line += "#";
					line2 += ".";
				} {
					line += "#";
					line2 += ".";
				} line += "#" line "#" line2 += "." line2 "." line2 = line2.substring(0, w-1)+"#" line2 line2.substring(0, w-1)+"#" line2.substring(0, w-1) line2.substring line2 0 w-1 w 1 "#" System.out.println(line) System.out.println System.out System System.out line for(int n=2; n<=h-1; n++){
					System.out.println(line2);
				} int n=2; int n=2; n 2 n<=h-1 n h-1 h 1 n++ n++ n {
					System.out.println(line2);
				} {
					System.out.println(line2);
				} System.out.println(line2) System.out.println System.out System System.out line2 System.out.println(line) System.out.println System.out System System.out line System.out.println() System.out.println System.out System System.out break; String[] args args public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		while(true){
			int h = Integer.parseInt(std.next());
			int w = Integer.parseInt(std.next());
			if(h!=0 && w!=0){
				String line = "";
				String line2 = "#";
				for(int m=1; m<=w; m++){
					line += "#";
					line2 += ".";
				}
				line2 = line2.substring(0, w-1)+"#";
				System.out.println(line);
				for(int n=2; n<=h-1; n++){
					System.out.println(line2);
				}
				System.out.println(line);
				System.out.println();
			}else break;
		}
	}
} public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		while(true){
			int h = Integer.parseInt(std.next());
			int w = Integer.parseInt(std.next());
			if(h!=0 && w!=0){
				String line = "";
				String line2 = "#";
				for(int m=1; m<=w; m++){
					line += "#";
					line2 += ".";
				}
				line2 = line2.substring(0, w-1)+"#";
				System.out.println(line);
				for(int n=2; n<=h-1; n++){
					System.out.println(line2);
				}
				System.out.println(line);
				System.out.println();
			}else break;
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		while(true){
			int h = Integer.parseInt(std.next());
			int w = Integer.parseInt(std.next());
			if(h!=0 && w!=0){
				String line = "";
				String line2 = "#";
				for(int m=1; m<=w; m++){
					line += "#";
					line2 += ".";
				}
				line2 = line2.substring(0, w-1)+"#";
				System.out.println(line);
				for(int n=2; n<=h-1; n++){
					System.out.println(line2);
				}
				System.out.println(line);
				System.out.println();
			}else break;
		}
	}
}