import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main{
	public static void main(String[]args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int H=0;
		int W=0;
		String[] arr;
		while((str=br.readLine())!=null){
			arr=str.split(" ");
			H=Integer.parseInt(arr[0]);
			W=Integer.parseInt(arr[1]);
			if((H==0)&&(W==0)){
				break;
			}
			for(int i=1;i<=H;i++){
				for(int j=1;j<=W;j++){
					if((i==1)||(i==H)||(j==1)||(j==W)) System.out.print("#");
					else System.out.print(".");
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
		br.close();
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main{
	public static void main(String[]args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int H=0;
		int W=0;
		String[] arr;
		while((str=br.readLine())!=null){
			arr=str.split(" ");
			H=Integer.parseInt(arr[0]);
			W=Integer.parseInt(arr[1]);
			if((H==0)&&(W==0)){
				break;
			}
			for(int i=1;i<=H;i++){
				for(int j=1;j<=W;j++){
					if((i==1)||(i==H)||(j==1)||(j==W)) System.out.print("#");
					else System.out.print(".");
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
		br.close();
	}
} Main public static void main(String[]args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int H=0;
		int W=0;
		String[] arr;
		while((str=br.readLine())!=null){
			arr=str.split(" ");
			H=Integer.parseInt(arr[0]);
			W=Integer.parseInt(arr[1]);
			if((H==0)&&(W==0)){
				break;
			}
			for(int i=1;i<=H;i++){
				for(int j=1;j<=W;j++){
					if((i==1)||(i==H)||(j==1)||(j==W)) System.out.print("#");
					else System.out.print(".");
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
		br.close();
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int H=0;
		int W=0;
		String[] arr;
		while((str=br.readLine())!=null){
			arr=str.split(" ");
			H=Integer.parseInt(arr[0]);
			W=Integer.parseInt(arr[1]);
			if((H==0)&&(W==0)){
				break;
			}
			for(int i=1;i<=H;i++){
				for(int j=1;j<=W;j++){
					if((i==1)||(i==H)||(j==1)||(j==W)) System.out.print("#");
					else System.out.print(".");
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
		br.close();
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str; str int H=0; H 0 int W=0; W 0 String[] arr; arr while((str=br.readLine())!=null){
			arr=str.split(" ");
			H=Integer.parseInt(arr[0]);
			W=Integer.parseInt(arr[1]);
			if((H==0)&&(W==0)){
				break;
			}
			for(int i=1;i<=H;i++){
				for(int j=1;j<=W;j++){
					if((i==1)||(i==H)||(j==1)||(j==W)) System.out.print("#");
					else System.out.print(".");
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		} (str=br.readLine())!=null (str=br.readLine()) str br.readLine() br.readLine br null {
			arr=str.split(" ");
			H=Integer.parseInt(arr[0]);
			W=Integer.parseInt(arr[1]);
			if((H==0)&&(W==0)){
				break;
			}
			for(int i=1;i<=H;i++){
				for(int j=1;j<=W;j++){
					if((i==1)||(i==H)||(j==1)||(j==W)) System.out.print("#");
					else System.out.print(".");
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		} arr=str.split(" ") arr str.split(" ") str.split str " " H=Integer.parseInt(arr[0]) H Integer.parseInt(arr[0]) Integer.parseInt Integer arr[0] arr 0 W=Integer.parseInt(arr[1]) W Integer.parseInt(arr[1]) Integer.parseInt Integer arr[1] arr 1 if((H==0)&&(W==0)){
				break;
			} (H==0)&&(W==0) (H==0) H 0 (W==0) W 0 {
				break;
			} break; for(int i=1;i<=H;i++){
				for(int j=1;j<=W;j++){
					if((i==1)||(i==H)||(j==1)||(j==W)) System.out.print("#");
					else System.out.print(".");
				}
				System.out.print("\n");
			} int i=1; int i=1; i 1 i<=H i H i++ i++ i {
				for(int j=1;j<=W;j++){
					if((i==1)||(i==H)||(j==1)||(j==W)) System.out.print("#");
					else System.out.print(".");
				}
				System.out.print("\n");
			} {
				for(int j=1;j<=W;j++){
					if((i==1)||(i==H)||(j==1)||(j==W)) System.out.print("#");
					else System.out.print(".");
				}
				System.out.print("\n");
			} for(int j=1;j<=W;j++){
					if((i==1)||(i==H)||(j==1)||(j==W)) System.out.print("#");
					else System.out.print(".");
				} int j=1; int j=1; j 1 j<=W j W j++ j++ j {
					if((i==1)||(i==H)||(j==1)||(j==W)) System.out.print("#");
					else System.out.print(".");
				} {
					if((i==1)||(i==H)||(j==1)||(j==W)) System.out.print("#");
					else System.out.print(".");
				} if((i==1)||(i==H)||(j==1)||(j==W)) System.out.print("#");
					else System.out.print("."); (i==1)||(i==H)||(j==1)||(j==W) (j==1) (i==1)||(i==H)||(j==1)||(j==W) (i==1) i 1 (i==H) i H (j==1) j 1 (j==W) j W System.out.print("#") System.out.print System.out System System.out "#" System.out.print(".") System.out.print System.out System System.out "." System.out.print("\n") System.out.print System.out System System.out "\n" System.out.print("\n") System.out.print System.out System System.out "\n" br.close() br.close br String[]args args public class Main{
	public static void main(String[]args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int H=0;
		int W=0;
		String[] arr;
		while((str=br.readLine())!=null){
			arr=str.split(" ");
			H=Integer.parseInt(arr[0]);
			W=Integer.parseInt(arr[1]);
			if((H==0)&&(W==0)){
				break;
			}
			for(int i=1;i<=H;i++){
				for(int j=1;j<=W;j++){
					if((i==1)||(i==H)||(j==1)||(j==W)) System.out.print("#");
					else System.out.print(".");
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
		br.close();
	}
} public class Main{
	public static void main(String[]args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int H=0;
		int W=0;
		String[] arr;
		while((str=br.readLine())!=null){
			arr=str.split(" ");
			H=Integer.parseInt(arr[0]);
			W=Integer.parseInt(arr[1]);
			if((H==0)&&(W==0)){
				break;
			}
			for(int i=1;i<=H;i++){
				for(int j=1;j<=W;j++){
					if((i==1)||(i==H)||(j==1)||(j==W)) System.out.print("#");
					else System.out.print(".");
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
		br.close();
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main{
	public static void main(String[]args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int H=0;
		int W=0;
		String[] arr;
		while((str=br.readLine())!=null){
			arr=str.split(" ");
			H=Integer.parseInt(arr[0]);
			W=Integer.parseInt(arr[1]);
			if((H==0)&&(W==0)){
				break;
			}
			for(int i=1;i<=H;i++){
				for(int j=1;j<=W;j++){
					if((i==1)||(i==H)||(j==1)||(j==W)) System.out.print("#");
					else System.out.print(".");
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
		br.close();
	}
}