import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder text = new StringBuilder();
		while (true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			if (H == 0 && W == 0) {
				scan.close();
				text.deleteCharAt(text.lastIndexOf("\n"));
				System.out.println(text.toString());
				break;
			} else {
				for(int i = 0;i < H;i++){
					for(int t = 0;t < W ;t++){
						if(i == 0 || i == H - 1 || t == 0 || t == W - 1)
							text.append("#");
						else
							text.append(".");
					}
					text.append("\n");
				}
				text.append("\n");
			}
		}
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder text = new StringBuilder();
		while (true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			if (H == 0 && W == 0) {
				scan.close();
				text.deleteCharAt(text.lastIndexOf("\n"));
				System.out.println(text.toString());
				break;
			} else {
				for(int i = 0;i < H;i++){
					for(int t = 0;t < W ;t++){
						if(i == 0 || i == H - 1 || t == 0 || t == W - 1)
							text.append("#");
						else
							text.append(".");
					}
					text.append("\n");
				}
				text.append("\n");
			}
		}
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder text = new StringBuilder();
		while (true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			if (H == 0 && W == 0) {
				scan.close();
				text.deleteCharAt(text.lastIndexOf("\n"));
				System.out.println(text.toString());
				break;
			} else {
				for(int i = 0;i < H;i++){
					for(int t = 0;t < W ;t++){
						if(i == 0 || i == H - 1 || t == 0 || t == W - 1)
							text.append("#");
						else
							text.append(".");
					}
					text.append("\n");
				}
				text.append("\n");
			}
		}
	} main {
		Scanner scan = new Scanner(System.in);
		StringBuilder text = new StringBuilder();
		while (true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			if (H == 0 && W == 0) {
				scan.close();
				text.deleteCharAt(text.lastIndexOf("\n"));
				System.out.println(text.toString());
				break;
			} else {
				for(int i = 0;i < H;i++){
					for(int t = 0;t < W ;t++){
						if(i == 0 || i == H - 1 || t == 0 || t == W - 1)
							text.append("#");
						else
							text.append(".");
					}
					text.append("\n");
				}
				text.append("\n");
			}
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) StringBuilder text = new StringBuilder(); text new StringBuilder() while (true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			if (H == 0 && W == 0) {
				scan.close();
				text.deleteCharAt(text.lastIndexOf("\n"));
				System.out.println(text.toString());
				break;
			} else {
				for(int i = 0;i < H;i++){
					for(int t = 0;t < W ;t++){
						if(i == 0 || i == H - 1 || t == 0 || t == W - 1)
							text.append("#");
						else
							text.append(".");
					}
					text.append("\n");
				}
				text.append("\n");
			}
		} true {
			int H = scan.nextInt();
			int W = scan.nextInt();
			if (H == 0 && W == 0) {
				scan.close();
				text.deleteCharAt(text.lastIndexOf("\n"));
				System.out.println(text.toString());
				break;
			} else {
				for(int i = 0;i < H;i++){
					for(int t = 0;t < W ;t++){
						if(i == 0 || i == H - 1 || t == 0 || t == W - 1)
							text.append("#");
						else
							text.append(".");
					}
					text.append("\n");
				}
				text.append("\n");
			}
		} int H = scan.nextInt(); H scan.nextInt() scan.nextInt scan int W = scan.nextInt(); W scan.nextInt() scan.nextInt scan if (H == 0 && W == 0) {
				scan.close();
				text.deleteCharAt(text.lastIndexOf("\n"));
				System.out.println(text.toString());
				break;
			} else {
				for(int i = 0;i < H;i++){
					for(int t = 0;t < W ;t++){
						if(i == 0 || i == H - 1 || t == 0 || t == W - 1)
							text.append("#");
						else
							text.append(".");
					}
					text.append("\n");
				}
				text.append("\n");
			} H == 0 && W == 0 H == 0 H 0 W == 0 W 0 {
				scan.close();
				text.deleteCharAt(text.lastIndexOf("\n"));
				System.out.println(text.toString());
				break;
			} scan.close() scan.close scan text.deleteCharAt(text.lastIndexOf("\n")) text.deleteCharAt text text.lastIndexOf("\n") text.lastIndexOf text "\n" System.out.println(text.toString()) System.out.println System.out System System.out text.toString() text.toString text break; {
				for(int i = 0;i < H;i++){
					for(int t = 0;t < W ;t++){
						if(i == 0 || i == H - 1 || t == 0 || t == W - 1)
							text.append("#");
						else
							text.append(".");
					}
					text.append("\n");
				}
				text.append("\n");
			} for(int i = 0;i < H;i++){
					for(int t = 0;t < W ;t++){
						if(i == 0 || i == H - 1 || t == 0 || t == W - 1)
							text.append("#");
						else
							text.append(".");
					}
					text.append("\n");
				} int i = 0; int i = 0; i 0 i < H i H i++ i++ i {
					for(int t = 0;t < W ;t++){
						if(i == 0 || i == H - 1 || t == 0 || t == W - 1)
							text.append("#");
						else
							text.append(".");
					}
					text.append("\n");
				} {
					for(int t = 0;t < W ;t++){
						if(i == 0 || i == H - 1 || t == 0 || t == W - 1)
							text.append("#");
						else
							text.append(".");
					}
					text.append("\n");
				} for(int t = 0;t < W ;t++){
						if(i == 0 || i == H - 1 || t == 0 || t == W - 1)
							text.append("#");
						else
							text.append(".");
					} int t = 0; int t = 0; t 0 t < W t W t++ t++ t {
						if(i == 0 || i == H - 1 || t == 0 || t == W - 1)
							text.append("#");
						else
							text.append(".");
					} {
						if(i == 0 || i == H - 1 || t == 0 || t == W - 1)
							text.append("#");
						else
							text.append(".");
					} if(i == 0 || i == H - 1 || t == 0 || t == W - 1)
							text.append("#");
						else
							text.append("."); i == 0 || i == H - 1 || t == 0 || t == W - 1 t == 0 i == 0 || i == H - 1 || t == 0 || t == W - 1 i == 0 i 0 i == H - 1 i H - 1 H 1 t == 0 t 0 t == W - 1 t W - 1 W 1 text.append("#") text.append text "#" text.append(".") text.append text "." text.append("\n") text.append text "\n" text.append("\n") text.append text "\n" String[] args args public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder text = new StringBuilder();
		while (true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			if (H == 0 && W == 0) {
				scan.close();
				text.deleteCharAt(text.lastIndexOf("\n"));
				System.out.println(text.toString());
				break;
			} else {
				for(int i = 0;i < H;i++){
					for(int t = 0;t < W ;t++){
						if(i == 0 || i == H - 1 || t == 0 || t == W - 1)
							text.append("#");
						else
							text.append(".");
					}
					text.append("\n");
				}
				text.append("\n");
			}
		}
	}
} public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder text = new StringBuilder();
		while (true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			if (H == 0 && W == 0) {
				scan.close();
				text.deleteCharAt(text.lastIndexOf("\n"));
				System.out.println(text.toString());
				break;
			} else {
				for(int i = 0;i < H;i++){
					for(int t = 0;t < W ;t++){
						if(i == 0 || i == H - 1 || t == 0 || t == W - 1)
							text.append("#");
						else
							text.append(".");
					}
					text.append("\n");
				}
				text.append("\n");
			}
		}
	}
} Main
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder text = new StringBuilder();
		while (true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			if (H == 0 && W == 0) {
				scan.close();
				text.deleteCharAt(text.lastIndexOf("\n"));
				System.out.println(text.toString());
				break;
			} else {
				for(int i = 0;i < H;i++){
					for(int t = 0;t < W ;t++){
						if(i == 0 || i == H - 1 || t == 0 || t == W - 1)
							text.append("#");
						else
							text.append(".");
					}
					text.append("\n");
				}
				text.append("\n");
			}
		}
	}
}