import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String[] str = null;
		for(;;) {
			str = br.readLine().split(" ");
			int h = Integer.parseInt(str[0]);
			int w = Integer.parseInt(str[1]);
			if(w==0&&h==0)break;
			for(int i=0;i<h;i++){
				System.out.print("#");
				for(int l=0;l<w-2;l++){
					if(i==0|i==h-1){System.out.print("#");
					}else System.out.print(".");
				}System.out.println("#");
				}System.out.println();
		}


	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String[] str = null;
		for(;;) {
			str = br.readLine().split(" ");
			int h = Integer.parseInt(str[0]);
			int w = Integer.parseInt(str[1]);
			if(w==0&&h==0)break;
			for(int i=0;i<h;i++){
				System.out.print("#");
				for(int l=0;l<w-2;l++){
					if(i==0|i==h-1){System.out.print("#");
					}else System.out.print(".");
				}System.out.println("#");
				}System.out.println();
		}


	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String[] str = null;
		for(;;) {
			str = br.readLine().split(" ");
			int h = Integer.parseInt(str[0]);
			int w = Integer.parseInt(str[1]);
			if(w==0&&h==0)break;
			for(int i=0;i<h;i++){
				System.out.print("#");
				for(int l=0;l<w-2;l++){
					if(i==0|i==h-1){System.out.print("#");
					}else System.out.print(".");
				}System.out.println("#");
				}System.out.println();
		}


	} main {
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String[] str = null;
		for(;;) {
			str = br.readLine().split(" ");
			int h = Integer.parseInt(str[0]);
			int w = Integer.parseInt(str[1]);
			if(w==0&&h==0)break;
			for(int i=0;i<h;i++){
				System.out.print("#");
				for(int l=0;l<w-2;l++){
					if(i==0|i==h-1){System.out.print("#");
					}else System.out.print(".");
				}System.out.println("#");
				}System.out.println();
		}


	} BufferedReader br =new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] str = null; str null for(;;) {
			str = br.readLine().split(" ");
			int h = Integer.parseInt(str[0]);
			int w = Integer.parseInt(str[1]);
			if(w==0&&h==0)break;
			for(int i=0;i<h;i++){
				System.out.print("#");
				for(int l=0;l<w-2;l++){
					if(i==0|i==h-1){System.out.print("#");
					}else System.out.print(".");
				}System.out.println("#");
				}System.out.println();
		} ; {
			str = br.readLine().split(" ");
			int h = Integer.parseInt(str[0]);
			int w = Integer.parseInt(str[1]);
			if(w==0&&h==0)break;
			for(int i=0;i<h;i++){
				System.out.print("#");
				for(int l=0;l<w-2;l++){
					if(i==0|i==h-1){System.out.print("#");
					}else System.out.print(".");
				}System.out.println("#");
				}System.out.println();
		} {
			str = br.readLine().split(" ");
			int h = Integer.parseInt(str[0]);
			int w = Integer.parseInt(str[1]);
			if(w==0&&h==0)break;
			for(int i=0;i<h;i++){
				System.out.print("#");
				for(int l=0;l<w-2;l++){
					if(i==0|i==h-1){System.out.print("#");
					}else System.out.print(".");
				}System.out.println("#");
				}System.out.println();
		} str = br.readLine().split(" ") str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int h = Integer.parseInt(str[0]); h Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int w = Integer.parseInt(str[1]); w Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 if(w==0&&h==0)break; w==0&&h==0 w==0 w 0 h==0 h 0 break; for(int i=0;i<h;i++){
				System.out.print("#");
				for(int l=0;l<w-2;l++){
					if(i==0|i==h-1){System.out.print("#");
					}else System.out.print(".");
				}System.out.println("#");
				} int i=0; int i=0; i 0 i<h i h i++ i++ i {
				System.out.print("#");
				for(int l=0;l<w-2;l++){
					if(i==0|i==h-1){System.out.print("#");
					}else System.out.print(".");
				}System.out.println("#");
				} {
				System.out.print("#");
				for(int l=0;l<w-2;l++){
					if(i==0|i==h-1){System.out.print("#");
					}else System.out.print(".");
				}System.out.println("#");
				} System.out.print("#") System.out.print System.out System System.out "#" for(int l=0;l<w-2;l++){
					if(i==0|i==h-1){System.out.print("#");
					}else System.out.print(".");
				} int l=0; int l=0; l 0 l<w-2 l w-2 w 2 l++ l++ l {
					if(i==0|i==h-1){System.out.print("#");
					}else System.out.print(".");
				} {
					if(i==0|i==h-1){System.out.print("#");
					}else System.out.print(".");
				} if(i==0|i==h-1){System.out.print("#");
					}else System.out.print("."); i==0|i==h-1 i==0 i 0 i==h-1 i h-1 h 1 {System.out.print("#");
					} 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) throws IOException {
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String[] str = null;
		for(;;) {
			str = br.readLine().split(" ");
			int h = Integer.parseInt(str[0]);
			int w = Integer.parseInt(str[1]);
			if(w==0&&h==0)break;
			for(int i=0;i<h;i++){
				System.out.print("#");
				for(int l=0;l<w-2;l++){
					if(i==0|i==h-1){System.out.print("#");
					}else System.out.print(".");
				}System.out.println("#");
				}System.out.println();
		}


	}
} public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String[] str = null;
		for(;;) {
			str = br.readLine().split(" ");
			int h = Integer.parseInt(str[0]);
			int w = Integer.parseInt(str[1]);
			if(w==0&&h==0)break;
			for(int i=0;i<h;i++){
				System.out.print("#");
				for(int l=0;l<w-2;l++){
					if(i==0|i==h-1){System.out.print("#");
					}else System.out.print(".");
				}System.out.println("#");
				}System.out.println();
		}


	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String[] str = null;
		for(;;) {
			str = br.readLine().split(" ");
			int h = Integer.parseInt(str[0]);
			int w = Integer.parseInt(str[1]);
			if(w==0&&h==0)break;
			for(int i=0;i<h;i++){
				System.out.print("#");
				for(int l=0;l<w-2;l++){
					if(i==0|i==h-1){System.out.print("#");
					}else System.out.print(".");
				}System.out.println("#");
				}System.out.println();
		}


	}
}