import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		int W,H,a,b;
		Scanner br = new Scanner(System.in);
		while(true){
			H=br.nextInt();
			W=br.nextInt();
			if(H==0 && W==0 ){
				break;
			}else{
				for(a=1;a<=H;a++){
					if(a==1 || a==H){
						for(b=1;b<=W;b++){
							System.out.print("#");
						}
						System.out.println();
					}else{
						for(b=1;b<=W;b++){
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						}
						System.out.println();
					}
				}
				System.out.println();
			}
		}
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args) {
		int W,H,a,b;
		Scanner br = new Scanner(System.in);
		while(true){
			H=br.nextInt();
			W=br.nextInt();
			if(H==0 && W==0 ){
				break;
			}else{
				for(a=1;a<=H;a++){
					if(a==1 || a==H){
						for(b=1;b<=W;b++){
							System.out.print("#");
						}
						System.out.println();
					}else{
						for(b=1;b<=W;b++){
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						}
						System.out.println();
					}
				}
				System.out.println();
			}
		}
	}
} Main public static void main(String[] args) {
		int W,H,a,b;
		Scanner br = new Scanner(System.in);
		while(true){
			H=br.nextInt();
			W=br.nextInt();
			if(H==0 && W==0 ){
				break;
			}else{
				for(a=1;a<=H;a++){
					if(a==1 || a==H){
						for(b=1;b<=W;b++){
							System.out.print("#");
						}
						System.out.println();
					}else{
						for(b=1;b<=W;b++){
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						}
						System.out.println();
					}
				}
				System.out.println();
			}
		}
	} main {
		int W,H,a,b;
		Scanner br = new Scanner(System.in);
		while(true){
			H=br.nextInt();
			W=br.nextInt();
			if(H==0 && W==0 ){
				break;
			}else{
				for(a=1;a<=H;a++){
					if(a==1 || a==H){
						for(b=1;b<=W;b++){
							System.out.print("#");
						}
						System.out.println();
					}else{
						for(b=1;b<=W;b++){
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						}
						System.out.println();
					}
				}
				System.out.println();
			}
		}
	} int W W H H a a b; b Scanner br = new Scanner(System.in); br new Scanner(System.in) while(true){
			H=br.nextInt();
			W=br.nextInt();
			if(H==0 && W==0 ){
				break;
			}else{
				for(a=1;a<=H;a++){
					if(a==1 || a==H){
						for(b=1;b<=W;b++){
							System.out.print("#");
						}
						System.out.println();
					}else{
						for(b=1;b<=W;b++){
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						}
						System.out.println();
					}
				}
				System.out.println();
			}
		} true {
			H=br.nextInt();
			W=br.nextInt();
			if(H==0 && W==0 ){
				break;
			}else{
				for(a=1;a<=H;a++){
					if(a==1 || a==H){
						for(b=1;b<=W;b++){
							System.out.print("#");
						}
						System.out.println();
					}else{
						for(b=1;b<=W;b++){
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						}
						System.out.println();
					}
				}
				System.out.println();
			}
		} H=br.nextInt() H br.nextInt() br.nextInt br W=br.nextInt() W br.nextInt() br.nextInt br if(H==0 && W==0 ){
				break;
			}else{
				for(a=1;a<=H;a++){
					if(a==1 || a==H){
						for(b=1;b<=W;b++){
							System.out.print("#");
						}
						System.out.println();
					}else{
						for(b=1;b<=W;b++){
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						}
						System.out.println();
					}
				}
				System.out.println();
			} H==0 && W==0 H==0 H 0 W==0 W 0 {
				break;
			} break; {
				for(a=1;a<=H;a++){
					if(a==1 || a==H){
						for(b=1;b<=W;b++){
							System.out.print("#");
						}
						System.out.println();
					}else{
						for(b=1;b<=W;b++){
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						}
						System.out.println();
					}
				}
				System.out.println();
			} for(a=1;a<=H;a++){
					if(a==1 || a==H){
						for(b=1;b<=W;b++){
							System.out.print("#");
						}
						System.out.println();
					}else{
						for(b=1;b<=W;b++){
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						}
						System.out.println();
					}
				} a=1; a=1 a 1 a<=H a H a++ a++ a {
					if(a==1 || a==H){
						for(b=1;b<=W;b++){
							System.out.print("#");
						}
						System.out.println();
					}else{
						for(b=1;b<=W;b++){
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						}
						System.out.println();
					}
				} {
					if(a==1 || a==H){
						for(b=1;b<=W;b++){
							System.out.print("#");
						}
						System.out.println();
					}else{
						for(b=1;b<=W;b++){
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						}
						System.out.println();
					}
				} if(a==1 || a==H){
						for(b=1;b<=W;b++){
							System.out.print("#");
						}
						System.out.println();
					}else{
						for(b=1;b<=W;b++){
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						}
						System.out.println();
					} a==1 || a==H a==1 a 1 a==H a H {
						for(b=1;b<=W;b++){
							System.out.print("#");
						}
						System.out.println();
					} for(b=1;b<=W;b++){
							System.out.print("#");
						} b=1; b=1 b 1 b<=W b W b++ b++ b {
							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(b=1;b<=W;b++){
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						}
						System.out.println();
					} for(b=1;b<=W;b++){
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						} b=1; b=1 b 1 b<=W b W b++ b++ b {
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						} {
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						} if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							} b==1 || b==W b==1 b 1 b==W b W {
								System.out.print("#");
							} System.out.print("#") System.out.print System.out System System.out "#" {
								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) {
		int W,H,a,b;
		Scanner br = new Scanner(System.in);
		while(true){
			H=br.nextInt();
			W=br.nextInt();
			if(H==0 && W==0 ){
				break;
			}else{
				for(a=1;a<=H;a++){
					if(a==1 || a==H){
						for(b=1;b<=W;b++){
							System.out.print("#");
						}
						System.out.println();
					}else{
						for(b=1;b<=W;b++){
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						}
						System.out.println();
					}
				}
				System.out.println();
			}
		}
	}
} public class Main{
	public static void main(String[] args) {
		int W,H,a,b;
		Scanner br = new Scanner(System.in);
		while(true){
			H=br.nextInt();
			W=br.nextInt();
			if(H==0 && W==0 ){
				break;
			}else{
				for(a=1;a<=H;a++){
					if(a==1 || a==H){
						for(b=1;b<=W;b++){
							System.out.print("#");
						}
						System.out.println();
					}else{
						for(b=1;b<=W;b++){
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						}
						System.out.println();
					}
				}
				System.out.println();
			}
		}
	}
} Main
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		int W,H,a,b;
		Scanner br = new Scanner(System.in);
		while(true){
			H=br.nextInt();
			W=br.nextInt();
			if(H==0 && W==0 ){
				break;
			}else{
				for(a=1;a<=H;a++){
					if(a==1 || a==H){
						for(b=1;b<=W;b++){
							System.out.print("#");
						}
						System.out.println();
					}else{
						for(b=1;b<=W;b++){
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						}
						System.out.println();
					}
				}
				System.out.println();
			}
		}
	}
}