import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner( System.in );
		
		while( true ) {
			int height	= sc.nextInt();
			int width	= sc.nextInt();
			
			if (		height	== 0
					&&	width	== 0	) {
				break;
			}
			
			for (int i = 0; i < height; i++ ) {
				if ( i == 0 || i == (height - 1) ) {
					frame( width );
					
				} else {
					content( width );
					
				}
				
				
			}
			System.out.print("\n");
			
		}
	}
	
	public static void frame( int width ) {
		for ( int j = 0; j < width; j++  ) {
			System.out.print("#");
		}
		
		System.out.print("\n");
	
	}
	
	public static void content( int width ) {
		System.out.print("#");

		for ( int j = 0; j < (width - 2); j++  ) {
			System.out.print(".");
		}

		System.out.println("#");	
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner( System.in );
		
		while( true ) {
			int height	= sc.nextInt();
			int width	= sc.nextInt();
			
			if (		height	== 0
					&&	width	== 0	) {
				break;
			}
			
			for (int i = 0; i < height; i++ ) {
				if ( i == 0 || i == (height - 1) ) {
					frame( width );
					
				} else {
					content( width );
					
				}
				
				
			}
			System.out.print("\n");
			
		}
	}
	
	public static void frame( int width ) {
		for ( int j = 0; j < width; j++  ) {
			System.out.print("#");
		}
		
		System.out.print("\n");
	
	}
	
	public static void content( int width ) {
		System.out.print("#");

		for ( int j = 0; j < (width - 2); j++  ) {
			System.out.print(".");
		}

		System.out.println("#");	
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner( System.in );
		
		while( true ) {
			int height	= sc.nextInt();
			int width	= sc.nextInt();
			
			if (		height	== 0
					&&	width	== 0	) {
				break;
			}
			
			for (int i = 0; i < height; i++ ) {
				if ( i == 0 || i == (height - 1) ) {
					frame( width );
					
				} else {
					content( width );
					
				}
				
				
			}
			System.out.print("\n");
			
		}
	} main {
		Scanner sc = new Scanner( System.in );
		
		while( true ) {
			int height	= sc.nextInt();
			int width	= sc.nextInt();
			
			if (		height	== 0
					&&	width	== 0	) {
				break;
			}
			
			for (int i = 0; i < height; i++ ) {
				if ( i == 0 || i == (height - 1) ) {
					frame( width );
					
				} else {
					content( width );
					
				}
				
				
			}
			System.out.print("\n");
			
		}
	} Scanner sc = new Scanner( System.in ); sc new Scanner( System.in ) while( true ) {
			int height	= sc.nextInt();
			int width	= sc.nextInt();
			
			if (		height	== 0
					&&	width	== 0	) {
				break;
			}
			
			for (int i = 0; i < height; i++ ) {
				if ( i == 0 || i == (height - 1) ) {
					frame( width );
					
				} else {
					content( width );
					
				}
				
				
			}
			System.out.print("\n");
			
		} true {
			int height	= sc.nextInt();
			int width	= sc.nextInt();
			
			if (		height	== 0
					&&	width	== 0	) {
				break;
			}
			
			for (int i = 0; i < height; i++ ) {
				if ( i == 0 || i == (height - 1) ) {
					frame( width );
					
				} else {
					content( width );
					
				}
				
				
			}
			System.out.print("\n");
			
		} int height	= sc.nextInt(); height sc.nextInt() sc.nextInt sc int width	= sc.nextInt(); width sc.nextInt() sc.nextInt sc if (		height	== 0
					&&	width	== 0	) {
				break;
			} height	== 0
					&&	width	== 0 height	== 0 height 0 width	== 0 width 0 {
				break;
			} break; for (int i = 0; i < height; i++ ) {
				if ( i == 0 || i == (height - 1) ) {
					frame( width );
					
				} else {
					content( width );
					
				}
				
				
			} int i = 0; int i = 0; i 0 i < height i height i++ i++ i {
				if ( i == 0 || i == (height - 1) ) {
					frame( width );
					
				} else {
					content( width );
					
				}
				
				
			} {
				if ( i == 0 || i == (height - 1) ) {
					frame( width );
					
				} else {
					content( width );
					
				}
				
				
			} if ( i == 0 || i == (height - 1) ) {
					frame( width );
					
				} else {
					content( width );
					
				} i == 0 || i == (height - 1) i == 0 i 0 i == (height - 1) i (height - 1) height 1 {
					frame( width );
					
				} frame( width ) frame width {
					content( width );
					
				} content( width ) content width System.out.print("\n") System.out.print System.out System System.out "\n" String[] args args public static void frame( int width ) {
		for ( int j = 0; j < width; j++  ) {
			System.out.print("#");
		}
		
		System.out.print("\n");
	
	} frame {
		for ( int j = 0; j < width; j++  ) {
			System.out.print("#");
		}
		
		System.out.print("\n");
	
	} for ( int j = 0; j < width; j++  ) {
			System.out.print("#");
		} int j = 0; int j = 0; j 0 j < width j width j++ j++ j {
			System.out.print("#");
		} {
			System.out.print("#");
		} System.out.print("#") System.out.print System.out System System.out "#" System.out.print("\n") System.out.print System.out System System.out "\n" int width width public static void content( int width ) {
		System.out.print("#");

		for ( int j = 0; j < (width - 2); j++  ) {
			System.out.print(".");
		}

		System.out.println("#");	
	} content {
		System.out.print("#");

		for ( int j = 0; j < (width - 2); j++  ) {
			System.out.print(".");
		}

		System.out.println("#");	
	} System.out.print("#") System.out.print System.out System System.out "#" for ( int j = 0; j < (width - 2); j++  ) {
			System.out.print(".");
		} int j = 0; int j = 0; j 0 j < (width - 2) j (width - 2) width 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 "#" int width width public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner( System.in );
		
		while( true ) {
			int height	= sc.nextInt();
			int width	= sc.nextInt();
			
			if (		height	== 0
					&&	width	== 0	) {
				break;
			}
			
			for (int i = 0; i < height; i++ ) {
				if ( i == 0 || i == (height - 1) ) {
					frame( width );
					
				} else {
					content( width );
					
				}
				
				
			}
			System.out.print("\n");
			
		}
	}
	
	public static void frame( int width ) {
		for ( int j = 0; j < width; j++  ) {
			System.out.print("#");
		}
		
		System.out.print("\n");
	
	}
	
	public static void content( int width ) {
		System.out.print("#");

		for ( int j = 0; j < (width - 2); j++  ) {
			System.out.print(".");
		}

		System.out.println("#");	
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner( System.in );
		
		while( true ) {
			int height	= sc.nextInt();
			int width	= sc.nextInt();
			
			if (		height	== 0
					&&	width	== 0	) {
				break;
			}
			
			for (int i = 0; i < height; i++ ) {
				if ( i == 0 || i == (height - 1) ) {
					frame( width );
					
				} else {
					content( width );
					
				}
				
				
			}
			System.out.print("\n");
			
		}
	}
	
	public static void frame( int width ) {
		for ( int j = 0; j < width; j++  ) {
			System.out.print("#");
		}
		
		System.out.print("\n");
	
	}
	
	public static void content( int width ) {
		System.out.print("#");

		for ( int j = 0; j < (width - 2); j++  ) {
			System.out.print(".");
		}

		System.out.println("#");	
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner( System.in );
		
		while( true ) {
			int height	= sc.nextInt();
			int width	= sc.nextInt();
			
			if (		height	== 0
					&&	width	== 0	) {
				break;
			}
			
			for (int i = 0; i < height; i++ ) {
				if ( i == 0 || i == (height - 1) ) {
					frame( width );
					
				} else {
					content( width );
					
				}
				
				
			}
			System.out.print("\n");
			
		}
	}
	
	public static void frame( int width ) {
		for ( int j = 0; j < width; j++  ) {
			System.out.print("#");
		}
		
		System.out.print("\n");
	
	}
	
	public static void content( int width ) {
		System.out.print("#");

		for ( int j = 0; j < (width - 2); j++  ) {
			System.out.print(".");
		}

		System.out.println("#");	
	}
}