import java.io.*;
public class Main {
	public static void main(String[] args){
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try{
        	while(true) {
        		String line = reader.readLine();
        		String[] num = line.split(" ", -1);
        		int H = Integer.parseInt(num[0]);
        		int W = Integer.parseInt(num[1]);
        		
        		if (H == 0 && W == 0) {
        			break;
        		} else {
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			for (int i = 0; i < (H - 2); i++) {
        				System.out.print("#");
        				for (int j = 0; j < (W - 2); j++) {
        					System.out.print(".");
        				}
        				System.out.println("#");
        			}
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			System.out.println();
        		}
        			
        	}
        } catch (IOException e) {
          System.out.println(e);
        } catch (NumberFormatException e) {
          System.out.println("error");
        }
    }
} import java.io.*; io.* java public class Main {
	public static void main(String[] args){
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try{
        	while(true) {
        		String line = reader.readLine();
        		String[] num = line.split(" ", -1);
        		int H = Integer.parseInt(num[0]);
        		int W = Integer.parseInt(num[1]);
        		
        		if (H == 0 && W == 0) {
        			break;
        		} else {
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			for (int i = 0; i < (H - 2); i++) {
        				System.out.print("#");
        				for (int j = 0; j < (W - 2); j++) {
        					System.out.print(".");
        				}
        				System.out.println("#");
        			}
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			System.out.println();
        		}
        			
        	}
        } catch (IOException e) {
          System.out.println(e);
        } catch (NumberFormatException e) {
          System.out.println("error");
        }
    }
} Main public static void main(String[] args){
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try{
        	while(true) {
        		String line = reader.readLine();
        		String[] num = line.split(" ", -1);
        		int H = Integer.parseInt(num[0]);
        		int W = Integer.parseInt(num[1]);
        		
        		if (H == 0 && W == 0) {
        			break;
        		} else {
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			for (int i = 0; i < (H - 2); i++) {
        				System.out.print("#");
        				for (int j = 0; j < (W - 2); j++) {
        					System.out.print(".");
        				}
        				System.out.println("#");
        			}
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			System.out.println();
        		}
        			
        	}
        } catch (IOException e) {
          System.out.println(e);
        } catch (NumberFormatException e) {
          System.out.println("error");
        }
    } main {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try{
        	while(true) {
        		String line = reader.readLine();
        		String[] num = line.split(" ", -1);
        		int H = Integer.parseInt(num[0]);
        		int W = Integer.parseInt(num[1]);
        		
        		if (H == 0 && W == 0) {
        			break;
        		} else {
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			for (int i = 0; i < (H - 2); i++) {
        				System.out.print("#");
        				for (int j = 0; j < (W - 2); j++) {
        					System.out.print(".");
        				}
        				System.out.println("#");
        			}
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			System.out.println();
        		}
        			
        	}
        } catch (IOException e) {
          System.out.println(e);
        } catch (NumberFormatException e) {
          System.out.println("error");
        }
    } BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) try{
        	while(true) {
        		String line = reader.readLine();
        		String[] num = line.split(" ", -1);
        		int H = Integer.parseInt(num[0]);
        		int W = Integer.parseInt(num[1]);
        		
        		if (H == 0 && W == 0) {
        			break;
        		} else {
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			for (int i = 0; i < (H - 2); i++) {
        				System.out.print("#");
        				for (int j = 0; j < (W - 2); j++) {
        					System.out.print(".");
        				}
        				System.out.println("#");
        			}
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			System.out.println();
        		}
        			
        	}
        } catch (IOException e) {
          System.out.println(e);
        } catch (NumberFormatException e) {
          System.out.println("error");
        } catch (IOException e) {
          System.out.println(e);
        } IOException e {
          System.out.println(e);
        } System.out.println(e) System.out.println System.out System System.out e catch (NumberFormatException e) {
          System.out.println("error");
        } NumberFormatException e {
          System.out.println("error");
        } System.out.println("error") System.out.println System.out System System.out "error" {
        	while(true) {
        		String line = reader.readLine();
        		String[] num = line.split(" ", -1);
        		int H = Integer.parseInt(num[0]);
        		int W = Integer.parseInt(num[1]);
        		
        		if (H == 0 && W == 0) {
        			break;
        		} else {
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			for (int i = 0; i < (H - 2); i++) {
        				System.out.print("#");
        				for (int j = 0; j < (W - 2); j++) {
        					System.out.print(".");
        				}
        				System.out.println("#");
        			}
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			System.out.println();
        		}
        			
        	}
        } while(true) {
        		String line = reader.readLine();
        		String[] num = line.split(" ", -1);
        		int H = Integer.parseInt(num[0]);
        		int W = Integer.parseInt(num[1]);
        		
        		if (H == 0 && W == 0) {
        			break;
        		} else {
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			for (int i = 0; i < (H - 2); i++) {
        				System.out.print("#");
        				for (int j = 0; j < (W - 2); j++) {
        					System.out.print(".");
        				}
        				System.out.println("#");
        			}
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			System.out.println();
        		}
        			
        	} true {
        		String line = reader.readLine();
        		String[] num = line.split(" ", -1);
        		int H = Integer.parseInt(num[0]);
        		int W = Integer.parseInt(num[1]);
        		
        		if (H == 0 && W == 0) {
        			break;
        		} else {
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			for (int i = 0; i < (H - 2); i++) {
        				System.out.print("#");
        				for (int j = 0; j < (W - 2); j++) {
        					System.out.print(".");
        				}
        				System.out.println("#");
        			}
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			System.out.println();
        		}
        			
        	} String line = reader.readLine(); line reader.readLine() reader.readLine reader String[] num = line.split(" ", -1); num line.split(" ", -1) line.split line " " -1 1 int H = Integer.parseInt(num[0]); H Integer.parseInt(num[0]) Integer.parseInt Integer num[0] num 0 int W = Integer.parseInt(num[1]); W Integer.parseInt(num[1]) Integer.parseInt Integer num[1] num 1 if (H == 0 && W == 0) {
        			break;
        		} else {
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			for (int i = 0; i < (H - 2); i++) {
        				System.out.print("#");
        				for (int j = 0; j < (W - 2); j++) {
        					System.out.print(".");
        				}
        				System.out.println("#");
        			}
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			System.out.println();
        		} H == 0 && W == 0 H == 0 H 0 W == 0 W 0 {
        			break;
        		} break; {
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			for (int i = 0; i < (H - 2); i++) {
        				System.out.print("#");
        				for (int j = 0; j < (W - 2); j++) {
        					System.out.print(".");
        				}
        				System.out.println("#");
        			}
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			System.out.println();
        		} for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			} int j = 0; int j = 0; j 0 j < W j W j++ j++ j {
        				System.out.print("#");
        			} {
        				System.out.print("#");
        			} System.out.print("#") System.out.print System.out System System.out "#" System.out.println() System.out.println System.out System System.out for (int i = 0; i < (H - 2); i++) {
        				System.out.print("#");
        				for (int j = 0; j < (W - 2); j++) {
        					System.out.print(".");
        				}
        				System.out.println("#");
        			} int i = 0; int i = 0; i 0 i < (H - 2) i (H - 2) H 2 i++ i++ i {
        				System.out.print("#");
        				for (int j = 0; j < (W - 2); j++) {
        					System.out.print(".");
        				}
        				System.out.println("#");
        			} {
        				System.out.print("#");
        				for (int j = 0; j < (W - 2); j++) {
        					System.out.print(".");
        				}
        				System.out.println("#");
        			} System.out.print("#") System.out.print System.out System System.out "#" for (int j = 0; j < (W - 2); j++) {
        					System.out.print(".");
        				} int j = 0; int j = 0; j 0 j < (W - 2) j (W - 2) W 2 j++ j++ j {
        					System.out.print(".");
        				} {
        					System.out.print(".");
        				} System.out.print(".") System.out.print System.out System System.out "." System.out.println("#") System.out.println System.out System System.out "#" for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			} int j = 0; int j = 0; j 0 j < W j W j++ j++ j {
        				System.out.print("#");
        			} {
        				System.out.print("#");
        			} 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){
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try{
        	while(true) {
        		String line = reader.readLine();
        		String[] num = line.split(" ", -1);
        		int H = Integer.parseInt(num[0]);
        		int W = Integer.parseInt(num[1]);
        		
        		if (H == 0 && W == 0) {
        			break;
        		} else {
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			for (int i = 0; i < (H - 2); i++) {
        				System.out.print("#");
        				for (int j = 0; j < (W - 2); j++) {
        					System.out.print(".");
        				}
        				System.out.println("#");
        			}
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			System.out.println();
        		}
        			
        	}
        } catch (IOException e) {
          System.out.println(e);
        } catch (NumberFormatException e) {
          System.out.println("error");
        }
    }
} public class Main {
	public static void main(String[] args){
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try{
        	while(true) {
        		String line = reader.readLine();
        		String[] num = line.split(" ", -1);
        		int H = Integer.parseInt(num[0]);
        		int W = Integer.parseInt(num[1]);
        		
        		if (H == 0 && W == 0) {
        			break;
        		} else {
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			for (int i = 0; i < (H - 2); i++) {
        				System.out.print("#");
        				for (int j = 0; j < (W - 2); j++) {
        					System.out.print(".");
        				}
        				System.out.println("#");
        			}
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			System.out.println();
        		}
        			
        	}
        } catch (IOException e) {
          System.out.println(e);
        } catch (NumberFormatException e) {
          System.out.println("error");
        }
    }
} Main
import java.io.*;
public class Main {
	public static void main(String[] args){
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try{
        	while(true) {
        		String line = reader.readLine();
        		String[] num = line.split(" ", -1);
        		int H = Integer.parseInt(num[0]);
        		int W = Integer.parseInt(num[1]);
        		
        		if (H == 0 && W == 0) {
        			break;
        		} else {
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			for (int i = 0; i < (H - 2); i++) {
        				System.out.print("#");
        				for (int j = 0; j < (W - 2); j++) {
        					System.out.print(".");
        				}
        				System.out.println("#");
        			}
        			for (int j = 0; j < W; j++) {
        				System.out.print("#");
        			}
        			System.out.println();
        			System.out.println();
        		}
        			
        	}
        } catch (IOException e) {
          System.out.println(e);
        } catch (NumberFormatException e) {
          System.out.println("error");
        }
    }
}