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


public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintStream out = System.out;

		while(true){
			StringBuilder sb = new StringBuilder();
			String[] str = in.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			if(H==0&&W==0)break;
			if(300<H||300<W)throw new RuntimeException("range over");
			for(int i=1; i<=H;i+=1){
				for(int j=1; j<=W; j+=1){
					if((2<=i && i<H)&&(2<=j&&j<W)){
						sb.append(".");
					}else {
						sb.append("#");
					}
				}
				sb.append(System.getProperty("line.separator"));
			}
			out.println(sb);
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.PrintStream; PrintStream java.io public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintStream out = System.out;

		while(true){
			StringBuilder sb = new StringBuilder();
			String[] str = in.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			if(H==0&&W==0)break;
			if(300<H||300<W)throw new RuntimeException("range over");
			for(int i=1; i<=H;i+=1){
				for(int j=1; j<=W; j+=1){
					if((2<=i && i<H)&&(2<=j&&j<W)){
						sb.append(".");
					}else {
						sb.append("#");
					}
				}
				sb.append(System.getProperty("line.separator"));
			}
			out.println(sb);
		}
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintStream out = System.out;

		while(true){
			StringBuilder sb = new StringBuilder();
			String[] str = in.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			if(H==0&&W==0)break;
			if(300<H||300<W)throw new RuntimeException("range over");
			for(int i=1; i<=H;i+=1){
				for(int j=1; j<=W; j+=1){
					if((2<=i && i<H)&&(2<=j&&j<W)){
						sb.append(".");
					}else {
						sb.append("#");
					}
				}
				sb.append(System.getProperty("line.separator"));
			}
			out.println(sb);
		}
	} main {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintStream out = System.out;

		while(true){
			StringBuilder sb = new StringBuilder();
			String[] str = in.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			if(H==0&&W==0)break;
			if(300<H||300<W)throw new RuntimeException("range over");
			for(int i=1; i<=H;i+=1){
				for(int j=1; j<=W; j+=1){
					if((2<=i && i<H)&&(2<=j&&j<W)){
						sb.append(".");
					}else {
						sb.append("#");
					}
				}
				sb.append(System.getProperty("line.separator"));
			}
			out.println(sb);
		}
	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) PrintStream out = System.out; out System.out System System.out while(true){
			StringBuilder sb = new StringBuilder();
			String[] str = in.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			if(H==0&&W==0)break;
			if(300<H||300<W)throw new RuntimeException("range over");
			for(int i=1; i<=H;i+=1){
				for(int j=1; j<=W; j+=1){
					if((2<=i && i<H)&&(2<=j&&j<W)){
						sb.append(".");
					}else {
						sb.append("#");
					}
				}
				sb.append(System.getProperty("line.separator"));
			}
			out.println(sb);
		} true {
			StringBuilder sb = new StringBuilder();
			String[] str = in.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			if(H==0&&W==0)break;
			if(300<H||300<W)throw new RuntimeException("range over");
			for(int i=1; i<=H;i+=1){
				for(int j=1; j<=W; j+=1){
					if((2<=i && i<H)&&(2<=j&&j<W)){
						sb.append(".");
					}else {
						sb.append("#");
					}
				}
				sb.append(System.getProperty("line.separator"));
			}
			out.println(sb);
		} StringBuilder sb = new StringBuilder(); sb new StringBuilder() String[] str = in.readLine().split(" "); str in.readLine().split(" ") in.readLine().split in.readLine() in.readLine in " " 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(H==0&&W==0)break; H==0&&W==0 H==0 H 0 W==0 W 0 break; if(300<H||300<W)throw new RuntimeException("range over"); 300<H||300<W 300<H 300 H 300<W 300 W throw new RuntimeException("range over"); new RuntimeException("range over") for(int i=1; i<=H;i+=1){
				for(int j=1; j<=W; j+=1){
					if((2<=i && i<H)&&(2<=j&&j<W)){
						sb.append(".");
					}else {
						sb.append("#");
					}
				}
				sb.append(System.getProperty("line.separator"));
			} int i=1; int i=1; i 1 i<=H i H i+=1 i+=1 i 1 {
				for(int j=1; j<=W; j+=1){
					if((2<=i && i<H)&&(2<=j&&j<W)){
						sb.append(".");
					}else {
						sb.append("#");
					}
				}
				sb.append(System.getProperty("line.separator"));
			} {
				for(int j=1; j<=W; j+=1){
					if((2<=i && i<H)&&(2<=j&&j<W)){
						sb.append(".");
					}else {
						sb.append("#");
					}
				}
				sb.append(System.getProperty("line.separator"));
			} for(int j=1; j<=W; j+=1){
					if((2<=i && i<H)&&(2<=j&&j<W)){
						sb.append(".");
					}else {
						sb.append("#");
					}
				} int j=1; int j=1; j 1 j<=W j W j+=1 j+=1 j 1 {
					if((2<=i && i<H)&&(2<=j&&j<W)){
						sb.append(".");
					}else {
						sb.append("#");
					}
				} {
					if((2<=i && i<H)&&(2<=j&&j<W)){
						sb.append(".");
					}else {
						sb.append("#");
					}
				} if((2<=i && i<H)&&(2<=j&&j<W)){
						sb.append(".");
					}else {
						sb.append("#");
					} (2<=i && i<H)&&(2<=j&&j<W) (2<=i && i<H) 2<=i 2 i i<H i H (2<=j&&j<W) 2<=j 2 j j<W j W {
						sb.append(".");
					} sb.append(".") sb.append sb "." {
						sb.append("#");
					} sb.append("#") sb.append sb "#" sb.append(System.getProperty("line.separator")) sb.append sb System.getProperty("line.separator") System.getProperty System "line.separator" out.println(sb) out.println out sb String[] args args public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintStream out = System.out;

		while(true){
			StringBuilder sb = new StringBuilder();
			String[] str = in.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			if(H==0&&W==0)break;
			if(300<H||300<W)throw new RuntimeException("range over");
			for(int i=1; i<=H;i+=1){
				for(int j=1; j<=W; j+=1){
					if((2<=i && i<H)&&(2<=j&&j<W)){
						sb.append(".");
					}else {
						sb.append("#");
					}
				}
				sb.append(System.getProperty("line.separator"));
			}
			out.println(sb);
		}
	}
} public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintStream out = System.out;

		while(true){
			StringBuilder sb = new StringBuilder();
			String[] str = in.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			if(H==0&&W==0)break;
			if(300<H||300<W)throw new RuntimeException("range over");
			for(int i=1; i<=H;i+=1){
				for(int j=1; j<=W; j+=1){
					if((2<=i && i<H)&&(2<=j&&j<W)){
						sb.append(".");
					}else {
						sb.append("#");
					}
				}
				sb.append(System.getProperty("line.separator"));
			}
			out.println(sb);
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;


public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintStream out = System.out;

		while(true){
			StringBuilder sb = new StringBuilder();
			String[] str = in.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			if(H==0&&W==0)break;
			if(300<H||300<W)throw new RuntimeException("range over");
			for(int i=1; i<=H;i+=1){
				for(int j=1; j<=W; j+=1){
					if((2<=i && i<H)&&(2<=j&&j<W)){
						sb.append(".");
					}else {
						sb.append("#");
					}
				}
				sb.append(System.getProperty("line.separator"));
			}
			out.println(sb);
		}
	}
}