import java.io.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		
		while(true) {
			String[] str = br.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			
			if(H==0 && W==0) {
				break;
			}
			
			for(int i=0; i<H; i++) {
				for(int j=0; j<W; j++) {
					if(i==0 || j==0 || i==H-1 || j==W-1) {
						sb.append("#");
					} else {
						sb.append(".");
					}
				}
				sb.append("\n");
			}
			sb.append("\n");
		}
		System.out.print(sb);
	}
} 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 = new StringBuilder();
		
		while(true) {
			String[] str = br.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			
			if(H==0 && W==0) {
				break;
			}
			
			for(int i=0; i<H; i++) {
				for(int j=0; j<W; j++) {
					if(i==0 || j==0 || i==H-1 || j==W-1) {
						sb.append("#");
					} else {
						sb.append(".");
					}
				}
				sb.append("\n");
			}
			sb.append("\n");
		}
		System.out.print(sb);
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		
		while(true) {
			String[] str = br.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			
			if(H==0 && W==0) {
				break;
			}
			
			for(int i=0; i<H; i++) {
				for(int j=0; j<W; j++) {
					if(i==0 || j==0 || i==H-1 || j==W-1) {
						sb.append("#");
					} else {
						sb.append(".");
					}
				}
				sb.append("\n");
			}
			sb.append("\n");
		}
		System.out.print(sb);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		
		while(true) {
			String[] str = br.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			
			if(H==0 && W==0) {
				break;
			}
			
			for(int i=0; i<H; i++) {
				for(int j=0; j<W; j++) {
					if(i==0 || j==0 || i==H-1 || j==W-1) {
						sb.append("#");
					} else {
						sb.append(".");
					}
				}
				sb.append("\n");
			}
			sb.append("\n");
		}
		System.out.print(sb);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() while(true) {
			String[] str = br.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			
			if(H==0 && W==0) {
				break;
			}
			
			for(int i=0; i<H; i++) {
				for(int j=0; j<W; j++) {
					if(i==0 || j==0 || i==H-1 || j==W-1) {
						sb.append("#");
					} else {
						sb.append(".");
					}
				}
				sb.append("\n");
			}
			sb.append("\n");
		} true {
			String[] str = br.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			
			if(H==0 && W==0) {
				break;
			}
			
			for(int i=0; i<H; i++) {
				for(int j=0; j<W; j++) {
					if(i==0 || j==0 || i==H-1 || j==W-1) {
						sb.append("#");
					} else {
						sb.append(".");
					}
				}
				sb.append("\n");
			}
			sb.append("\n");
		} String[] str = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int H = Integer.parseInt(str[0]); H Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int W = Integer.parseInt(str[1]); W Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 if(H==0 && W==0) {
				break;
			} H==0 && W==0 H==0 H 0 W==0 W 0 {
				break;
			} break; for(int i=0; i<H; i++) {
				for(int j=0; j<W; j++) {
					if(i==0 || j==0 || i==H-1 || j==W-1) {
						sb.append("#");
					} else {
						sb.append(".");
					}
				}
				sb.append("\n");
			} int i=0; int i=0; i 0 i<H i H i++ i++ i {
				for(int j=0; j<W; j++) {
					if(i==0 || j==0 || i==H-1 || j==W-1) {
						sb.append("#");
					} else {
						sb.append(".");
					}
				}
				sb.append("\n");
			} {
				for(int j=0; j<W; j++) {
					if(i==0 || j==0 || i==H-1 || j==W-1) {
						sb.append("#");
					} else {
						sb.append(".");
					}
				}
				sb.append("\n");
			} for(int j=0; j<W; j++) {
					if(i==0 || j==0 || i==H-1 || j==W-1) {
						sb.append("#");
					} else {
						sb.append(".");
					}
				} int j=0; int j=0; j 0 j<W j W j++ j++ j {
					if(i==0 || j==0 || i==H-1 || j==W-1) {
						sb.append("#");
					} else {
						sb.append(".");
					}
				} {
					if(i==0 || j==0 || i==H-1 || j==W-1) {
						sb.append("#");
					} else {
						sb.append(".");
					}
				} if(i==0 || j==0 || i==H-1 || j==W-1) {
						sb.append("#");
					} else {
						sb.append(".");
					} i==0 || j==0 || i==H-1 || j==W-1 i==H-1 i==0 || j==0 || i==H-1 || j==W-1 i==0 i 0 j==0 j 0 i==H-1 i H-1 H 1 j==W-1 j W-1 W 1 {
						sb.append("#");
					} sb.append("#") sb.append sb "#" {
						sb.append(".");
					} sb.append(".") sb.append sb "." sb.append("\n") sb.append sb "\n" sb.append("\n") sb.append sb "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args public class Main {
	
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		
		while(true) {
			String[] str = br.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			
			if(H==0 && W==0) {
				break;
			}
			
			for(int i=0; i<H; i++) {
				for(int j=0; j<W; j++) {
					if(i==0 || j==0 || i==H-1 || j==W-1) {
						sb.append("#");
					} else {
						sb.append(".");
					}
				}
				sb.append("\n");
			}
			sb.append("\n");
		}
		System.out.print(sb);
	}
} public class Main {
	
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		
		while(true) {
			String[] str = br.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			
			if(H==0 && W==0) {
				break;
			}
			
			for(int i=0; i<H; i++) {
				for(int j=0; j<W; j++) {
					if(i==0 || j==0 || i==H-1 || j==W-1) {
						sb.append("#");
					} else {
						sb.append(".");
					}
				}
				sb.append("\n");
			}
			sb.append("\n");
		}
		System.out.print(sb);
	}
} 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 = new StringBuilder();
		
		while(true) {
			String[] str = br.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			
			if(H==0 && W==0) {
				break;
			}
			
			for(int i=0; i<H; i++) {
				for(int j=0; j<W; j++) {
					if(i==0 || j==0 || i==H-1 || j==W-1) {
						sb.append("#");
					} else {
						sb.append(".");
					}
				}
				sb.append("\n");
			}
			sb.append("\n");
		}
		System.out.print(sb);
	}
}