import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb;
		String[] strs;
		int  height, width;
		do {
			sb		= new StringBuilder();
			strs	= br.readLine().split("\\s+");
			height	= Integer.parseInt(strs[0]);
			width	= Integer.parseInt(strs[1]);
			
			if (height == 0 && width == 0) {
				break;
			} else {
				System.out.println(getFrame(height, width));
			}
		} while (true);
	}
	
	public static String getFrame(int height, int width) {
		StringBuilder sb = new StringBuilder();
		String str;
		
		for (int i = 0; i < height; i++) {
			for (int j = 0; j < width; j++) {
				if (i == 0 || i == (height - 1) || j == 0 || j == (width - 1)) {
					str = "#";
				} else {
					str = ".";
				}
				sb.append(str);
			}
			sb.append("\n");
		}
		
		return sb.toString();
	}
} import java.io.*; io.* java public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb;
		String[] strs;
		int  height, width;
		do {
			sb		= new StringBuilder();
			strs	= br.readLine().split("\\s+");
			height	= Integer.parseInt(strs[0]);
			width	= Integer.parseInt(strs[1]);
			
			if (height == 0 && width == 0) {
				break;
			} else {
				System.out.println(getFrame(height, width));
			}
		} while (true);
	}
	
	public static String getFrame(int height, int width) {
		StringBuilder sb = new StringBuilder();
		String str;
		
		for (int i = 0; i < height; i++) {
			for (int j = 0; j < width; j++) {
				if (i == 0 || i == (height - 1) || j == 0 || j == (width - 1)) {
					str = "#";
				} else {
					str = ".";
				}
				sb.append(str);
			}
			sb.append("\n");
		}
		
		return sb.toString();
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb;
		String[] strs;
		int  height, width;
		do {
			sb		= new StringBuilder();
			strs	= br.readLine().split("\\s+");
			height	= Integer.parseInt(strs[0]);
			width	= Integer.parseInt(strs[1]);
			
			if (height == 0 && width == 0) {
				break;
			} else {
				System.out.println(getFrame(height, width));
			}
		} while (true);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb;
		String[] strs;
		int  height, width;
		do {
			sb		= new StringBuilder();
			strs	= br.readLine().split("\\s+");
			height	= Integer.parseInt(strs[0]);
			width	= Integer.parseInt(strs[1]);
			
			if (height == 0 && width == 0) {
				break;
			} else {
				System.out.println(getFrame(height, width));
			}
		} while (true);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb; sb String[] strs; strs int  height height width; width do {
			sb		= new StringBuilder();
			strs	= br.readLine().split("\\s+");
			height	= Integer.parseInt(strs[0]);
			width	= Integer.parseInt(strs[1]);
			
			if (height == 0 && width == 0) {
				break;
			} else {
				System.out.println(getFrame(height, width));
			}
		} while (true); true {
			sb		= new StringBuilder();
			strs	= br.readLine().split("\\s+");
			height	= Integer.parseInt(strs[0]);
			width	= Integer.parseInt(strs[1]);
			
			if (height == 0 && width == 0) {
				break;
			} else {
				System.out.println(getFrame(height, width));
			}
		} sb		= new StringBuilder() sb new StringBuilder() strs	= br.readLine().split("\\s+") strs br.readLine().split("\\s+") br.readLine().split br.readLine() br.readLine br "\\s+" height	= Integer.parseInt(strs[0]) height Integer.parseInt(strs[0]) Integer.parseInt Integer strs[0] strs 0 width	= Integer.parseInt(strs[1]) width Integer.parseInt(strs[1]) Integer.parseInt Integer strs[1] strs 1 if (height == 0 && width == 0) {
				break;
			} else {
				System.out.println(getFrame(height, width));
			} height == 0 && width == 0 height == 0 height 0 width == 0 width 0 {
				break;
			} break; {
				System.out.println(getFrame(height, width));
			} System.out.println(getFrame(height, width)) System.out.println System.out System System.out getFrame(height, width) getFrame height width String[] args args public static String getFrame(int height, int width) {
		StringBuilder sb = new StringBuilder();
		String str;
		
		for (int i = 0; i < height; i++) {
			for (int j = 0; j < width; j++) {
				if (i == 0 || i == (height - 1) || j == 0 || j == (width - 1)) {
					str = "#";
				} else {
					str = ".";
				}
				sb.append(str);
			}
			sb.append("\n");
		}
		
		return sb.toString();
	} getFrame {
		StringBuilder sb = new StringBuilder();
		String str;
		
		for (int i = 0; i < height; i++) {
			for (int j = 0; j < width; j++) {
				if (i == 0 || i == (height - 1) || j == 0 || j == (width - 1)) {
					str = "#";
				} else {
					str = ".";
				}
				sb.append(str);
			}
			sb.append("\n");
		}
		
		return sb.toString();
	} StringBuilder sb = new StringBuilder(); sb new StringBuilder() String str; str for (int i = 0; i < height; i++) {
			for (int j = 0; j < width; j++) {
				if (i == 0 || i == (height - 1) || j == 0 || j == (width - 1)) {
					str = "#";
				} else {
					str = ".";
				}
				sb.append(str);
			}
			sb.append("\n");
		} int i = 0; int i = 0; i 0 i < height i height i++ i++ i {
			for (int j = 0; j < width; j++) {
				if (i == 0 || i == (height - 1) || j == 0 || j == (width - 1)) {
					str = "#";
				} else {
					str = ".";
				}
				sb.append(str);
			}
			sb.append("\n");
		} {
			for (int j = 0; j < width; j++) {
				if (i == 0 || i == (height - 1) || j == 0 || j == (width - 1)) {
					str = "#";
				} else {
					str = ".";
				}
				sb.append(str);
			}
			sb.append("\n");
		} for (int j = 0; j < width; j++) {
				if (i == 0 || i == (height - 1) || j == 0 || j == (width - 1)) {
					str = "#";
				} else {
					str = ".";
				}
				sb.append(str);
			} int j = 0; int j = 0; j 0 j < width j width j++ j++ j {
				if (i == 0 || i == (height - 1) || j == 0 || j == (width - 1)) {
					str = "#";
				} else {
					str = ".";
				}
				sb.append(str);
			} {
				if (i == 0 || i == (height - 1) || j == 0 || j == (width - 1)) {
					str = "#";
				} else {
					str = ".";
				}
				sb.append(str);
			} if (i == 0 || i == (height - 1) || j == 0 || j == (width - 1)) {
					str = "#";
				} else {
					str = ".";
				} i == 0 || i == (height - 1) || j == 0 || j == (width - 1) j == 0 i == 0 || i == (height - 1) || j == 0 || j == (width - 1) i == 0 i 0 i == (height - 1) i (height - 1) height 1 j == 0 j 0 j == (width - 1) j (width - 1) width 1 {
					str = "#";
				} str = "#" str "#" {
					str = ".";
				} str = "." str "." sb.append(str) sb.append sb str sb.append("\n") sb.append sb "\n" return sb.toString(); sb.toString() sb.toString sb int height height int width width public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb;
		String[] strs;
		int  height, width;
		do {
			sb		= new StringBuilder();
			strs	= br.readLine().split("\\s+");
			height	= Integer.parseInt(strs[0]);
			width	= Integer.parseInt(strs[1]);
			
			if (height == 0 && width == 0) {
				break;
			} else {
				System.out.println(getFrame(height, width));
			}
		} while (true);
	}
	
	public static String getFrame(int height, int width) {
		StringBuilder sb = new StringBuilder();
		String str;
		
		for (int i = 0; i < height; i++) {
			for (int j = 0; j < width; j++) {
				if (i == 0 || i == (height - 1) || j == 0 || j == (width - 1)) {
					str = "#";
				} else {
					str = ".";
				}
				sb.append(str);
			}
			sb.append("\n");
		}
		
		return sb.toString();
	}
} public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb;
		String[] strs;
		int  height, width;
		do {
			sb		= new StringBuilder();
			strs	= br.readLine().split("\\s+");
			height	= Integer.parseInt(strs[0]);
			width	= Integer.parseInt(strs[1]);
			
			if (height == 0 && width == 0) {
				break;
			} else {
				System.out.println(getFrame(height, width));
			}
		} while (true);
	}
	
	public static String getFrame(int height, int width) {
		StringBuilder sb = new StringBuilder();
		String str;
		
		for (int i = 0; i < height; i++) {
			for (int j = 0; j < width; j++) {
				if (i == 0 || i == (height - 1) || j == 0 || j == (width - 1)) {
					str = "#";
				} else {
					str = ".";
				}
				sb.append(str);
			}
			sb.append("\n");
		}
		
		return sb.toString();
	}
} Main
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb;
		String[] strs;
		int  height, width;
		do {
			sb		= new StringBuilder();
			strs	= br.readLine().split("\\s+");
			height	= Integer.parseInt(strs[0]);
			width	= Integer.parseInt(strs[1]);
			
			if (height == 0 && width == 0) {
				break;
			} else {
				System.out.println(getFrame(height, width));
			}
		} while (true);
	}
	
	public static String getFrame(int height, int width) {
		StringBuilder sb = new StringBuilder();
		String str;
		
		for (int i = 0; i < height; i++) {
			for (int j = 0; j < width; j++) {
				if (i == 0 || i == (height - 1) || j == 0 || j == (width - 1)) {
					str = "#";
				} else {
					str = ".";
				}
				sb.append(str);
			}
			sb.append("\n");
		}
		
		return sb.toString();
	}
}