import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);

		int H[]=new int[256];
		int W[]=new int[256];

		int i=0;
		while(true){
			H[i]=sc.nextInt();
			W[i]=sc.nextInt();

			if(H[i]==0&&W[i]==0)	break;
			i++;
		}

		for(int x=0;x<i;x++){
			for(int j=0;j<H[x];j++){
				for(int k=0;k<W[x];k++){
					if(j==0||j==H[x]-1||k==0||k==W[x]-1)	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) {
		Scanner sc=new Scanner(System.in);

		int H[]=new int[256];
		int W[]=new int[256];

		int i=0;
		while(true){
			H[i]=sc.nextInt();
			W[i]=sc.nextInt();

			if(H[i]==0&&W[i]==0)	break;
			i++;
		}

		for(int x=0;x<i;x++){
			for(int j=0;j<H[x];j++){
				for(int k=0;k<W[x];k++){
					if(j==0||j==H[x]-1||k==0||k==W[x]-1)	System.out.print("#");
					else	System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
} Main public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);

		int H[]=new int[256];
		int W[]=new int[256];

		int i=0;
		while(true){
			H[i]=sc.nextInt();
			W[i]=sc.nextInt();

			if(H[i]==0&&W[i]==0)	break;
			i++;
		}

		for(int x=0;x<i;x++){
			for(int j=0;j<H[x];j++){
				for(int k=0;k<W[x];k++){
					if(j==0||j==H[x]-1||k==0||k==W[x]-1)	System.out.print("#");
					else	System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
	} main {
		Scanner sc=new Scanner(System.in);

		int H[]=new int[256];
		int W[]=new int[256];

		int i=0;
		while(true){
			H[i]=sc.nextInt();
			W[i]=sc.nextInt();

			if(H[i]==0&&W[i]==0)	break;
			i++;
		}

		for(int x=0;x<i;x++){
			for(int j=0;j<H[x];j++){
				for(int k=0;k<W[x];k++){
					if(j==0||j==H[x]-1||k==0||k==W[x]-1)	System.out.print("#");
					else	System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int H[]=new int[256]; H new int[256] 256 int W[]=new int[256]; W new int[256] 256 int i=0; i 0 while(true){
			H[i]=sc.nextInt();
			W[i]=sc.nextInt();

			if(H[i]==0&&W[i]==0)	break;
			i++;
		} true {
			H[i]=sc.nextInt();
			W[i]=sc.nextInt();

			if(H[i]==0&&W[i]==0)	break;
			i++;
		} H[i]=sc.nextInt() H[i] H i sc.nextInt() sc.nextInt sc W[i]=sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc if(H[i]==0&&W[i]==0)	break; H[i]==0&&W[i]==0 H[i]==0 H[i] H i 0 W[i]==0 W[i] W i 0 break; i++ i for(int x=0;x<i;x++){
			for(int j=0;j<H[x];j++){
				for(int k=0;k<W[x];k++){
					if(j==0||j==H[x]-1||k==0||k==W[x]-1)	System.out.print("#");
					else	System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		} int x=0; int x=0; x 0 x<i x i x++ x++ x {
			for(int j=0;j<H[x];j++){
				for(int k=0;k<W[x];k++){
					if(j==0||j==H[x]-1||k==0||k==W[x]-1)	System.out.print("#");
					else	System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		} {
			for(int j=0;j<H[x];j++){
				for(int k=0;k<W[x];k++){
					if(j==0||j==H[x]-1||k==0||k==W[x]-1)	System.out.print("#");
					else	System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		} for(int j=0;j<H[x];j++){
				for(int k=0;k<W[x];k++){
					if(j==0||j==H[x]-1||k==0||k==W[x]-1)	System.out.print("#");
					else	System.out.print(".");
				}
				System.out.println();
			} int j=0; int j=0; j 0 j<H[x] j H[x] H x j++ j++ j {
				for(int k=0;k<W[x];k++){
					if(j==0||j==H[x]-1||k==0||k==W[x]-1)	System.out.print("#");
					else	System.out.print(".");
				}
				System.out.println();
			} {
				for(int k=0;k<W[x];k++){
					if(j==0||j==H[x]-1||k==0||k==W[x]-1)	System.out.print("#");
					else	System.out.print(".");
				}
				System.out.println();
			} for(int k=0;k<W[x];k++){
					if(j==0||j==H[x]-1||k==0||k==W[x]-1)	System.out.print("#");
					else	System.out.print(".");
				} int k=0; int k=0; k 0 k<W[x] k W[x] W x k++ k++ k {
					if(j==0||j==H[x]-1||k==0||k==W[x]-1)	System.out.print("#");
					else	System.out.print(".");
				} {
					if(j==0||j==H[x]-1||k==0||k==W[x]-1)	System.out.print("#");
					else	System.out.print(".");
				} if(j==0||j==H[x]-1||k==0||k==W[x]-1)	System.out.print("#");
					else	System.out.print("."); j==0||j==H[x]-1||k==0||k==W[x]-1 k==0 j==0||j==H[x]-1||k==0||k==W[x]-1 j==0 j 0 j==H[x]-1 j H[x]-1 H[x] H x 1 k==0 k 0 k==W[x]-1 k W[x]-1 W[x] W x 1 System.out.print("#") System.out.print System.out System System.out "#" 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) {
		Scanner sc=new Scanner(System.in);

		int H[]=new int[256];
		int W[]=new int[256];

		int i=0;
		while(true){
			H[i]=sc.nextInt();
			W[i]=sc.nextInt();

			if(H[i]==0&&W[i]==0)	break;
			i++;
		}

		for(int x=0;x<i;x++){
			for(int j=0;j<H[x];j++){
				for(int k=0;k<W[x];k++){
					if(j==0||j==H[x]-1||k==0||k==W[x]-1)	System.out.print("#");
					else	System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);

		int H[]=new int[256];
		int W[]=new int[256];

		int i=0;
		while(true){
			H[i]=sc.nextInt();
			W[i]=sc.nextInt();

			if(H[i]==0&&W[i]==0)	break;
			i++;
		}

		for(int x=0;x<i;x++){
			for(int j=0;j<H[x];j++){
				for(int k=0;k<W[x];k++){
					if(j==0||j==H[x]-1||k==0||k==W[x]-1)	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) {
		Scanner sc=new Scanner(System.in);

		int H[]=new int[256];
		int W[]=new int[256];

		int i=0;
		while(true){
			H[i]=sc.nextInt();
			W[i]=sc.nextInt();

			if(H[i]==0&&W[i]==0)	break;
			i++;
		}

		for(int x=0;x<i;x++){
			for(int j=0;j<H[x];j++){
				for(int k=0;k<W[x];k++){
					if(j==0||j==H[x]-1||k==0||k==W[x]-1)	System.out.print("#");
					else	System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}