import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		StringBuilder sb=new StringBuilder("");
		Scanner n=new Scanner(System.in);
		int a=n.nextInt();
		int b=n.nextInt();
		while (a!=0 || b!=0){
			for (int c=0;c<b;c++){
					sb.append("#");
			}
			System.out.println(sb);
			sb.append("\n");//改行
			sb=new StringBuilder("#");
			for (int d=2;d<a;d++){
				for (int e=2;e<b;e++){
					sb.append(".");
				}
				sb.append("#");
				System.out.println(sb);
				sb.append("\n");//改行
				sb=new StringBuilder("#");
			}
			for (int c=1;c<b;c++){
				sb.append("#");
			}
		sb.append("\n");//改行
		System.out.println(sb);
		a=n.nextInt();b=n.nextInt();
		sb=new StringBuilder("");
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		StringBuilder sb=new StringBuilder("");
		Scanner n=new Scanner(System.in);
		int a=n.nextInt();
		int b=n.nextInt();
		while (a!=0 || b!=0){
			for (int c=0;c<b;c++){
					sb.append("#");
			}
			System.out.println(sb);
			sb.append("\n");//改行
			sb=new StringBuilder("#");
			for (int d=2;d<a;d++){
				for (int e=2;e<b;e++){
					sb.append(".");
				}
				sb.append("#");
				System.out.println(sb);
				sb.append("\n");//改行
				sb=new StringBuilder("#");
			}
			for (int c=1;c<b;c++){
				sb.append("#");
			}
		sb.append("\n");//改行
		System.out.println(sb);
		a=n.nextInt();b=n.nextInt();
		sb=new StringBuilder("");
		}
	}
} Main public static void main(String[] args) {
		StringBuilder sb=new StringBuilder("");
		Scanner n=new Scanner(System.in);
		int a=n.nextInt();
		int b=n.nextInt();
		while (a!=0 || b!=0){
			for (int c=0;c<b;c++){
					sb.append("#");
			}
			System.out.println(sb);
			sb.append("\n");//改行
			sb=new StringBuilder("#");
			for (int d=2;d<a;d++){
				for (int e=2;e<b;e++){
					sb.append(".");
				}
				sb.append("#");
				System.out.println(sb);
				sb.append("\n");//改行
				sb=new StringBuilder("#");
			}
			for (int c=1;c<b;c++){
				sb.append("#");
			}
		sb.append("\n");//改行
		System.out.println(sb);
		a=n.nextInt();b=n.nextInt();
		sb=new StringBuilder("");
		}
	} main {
		StringBuilder sb=new StringBuilder("");
		Scanner n=new Scanner(System.in);
		int a=n.nextInt();
		int b=n.nextInt();
		while (a!=0 || b!=0){
			for (int c=0;c<b;c++){
					sb.append("#");
			}
			System.out.println(sb);
			sb.append("\n");//改行
			sb=new StringBuilder("#");
			for (int d=2;d<a;d++){
				for (int e=2;e<b;e++){
					sb.append(".");
				}
				sb.append("#");
				System.out.println(sb);
				sb.append("\n");//改行
				sb=new StringBuilder("#");
			}
			for (int c=1;c<b;c++){
				sb.append("#");
			}
		sb.append("\n");//改行
		System.out.println(sb);
		a=n.nextInt();b=n.nextInt();
		sb=new StringBuilder("");
		}
	} StringBuilder sb=new StringBuilder(""); sb new StringBuilder("") Scanner n=new Scanner(System.in); n new Scanner(System.in) int a=n.nextInt(); a n.nextInt() n.nextInt n int b=n.nextInt(); b n.nextInt() n.nextInt n while (a!=0 || b!=0){
			for (int c=0;c<b;c++){
					sb.append("#");
			}
			System.out.println(sb);
			sb.append("\n");//改行
			sb=new StringBuilder("#");
			for (int d=2;d<a;d++){
				for (int e=2;e<b;e++){
					sb.append(".");
				}
				sb.append("#");
				System.out.println(sb);
				sb.append("\n");//改行
				sb=new StringBuilder("#");
			}
			for (int c=1;c<b;c++){
				sb.append("#");
			}
		sb.append("\n");//改行
		System.out.println(sb);
		a=n.nextInt();b=n.nextInt();
		sb=new StringBuilder("");
		} a!=0 || b!=0 a!=0 a 0 b!=0 b 0 {
			for (int c=0;c<b;c++){
					sb.append("#");
			}
			System.out.println(sb);
			sb.append("\n");//改行
			sb=new StringBuilder("#");
			for (int d=2;d<a;d++){
				for (int e=2;e<b;e++){
					sb.append(".");
				}
				sb.append("#");
				System.out.println(sb);
				sb.append("\n");//改行
				sb=new StringBuilder("#");
			}
			for (int c=1;c<b;c++){
				sb.append("#");
			}
		sb.append("\n");//改行
		System.out.println(sb);
		a=n.nextInt();b=n.nextInt();
		sb=new StringBuilder("");
		} for (int c=0;c<b;c++){
					sb.append("#");
			} int c=0; int c=0; c 0 c<b c b c++ c++ c {
					sb.append("#");
			} {
					sb.append("#");
			} sb.append("#") sb.append sb "#" System.out.println(sb) System.out.println System.out System System.out sb sb.append("\n") sb.append sb "\n" sb=new StringBuilder("#") sb new StringBuilder("#") for (int d=2;d<a;d++){
				for (int e=2;e<b;e++){
					sb.append(".");
				}
				sb.append("#");
				System.out.println(sb);
				sb.append("\n");//改行
				sb=new StringBuilder("#");
			} int d=2; int d=2; d 2 d<a d a d++ d++ d {
				for (int e=2;e<b;e++){
					sb.append(".");
				}
				sb.append("#");
				System.out.println(sb);
				sb.append("\n");//改行
				sb=new StringBuilder("#");
			} {
				for (int e=2;e<b;e++){
					sb.append(".");
				}
				sb.append("#");
				System.out.println(sb);
				sb.append("\n");//改行
				sb=new StringBuilder("#");
			} for (int e=2;e<b;e++){
					sb.append(".");
				} int e=2; int e=2; e 2 e<b e b e++ e++ e {
					sb.append(".");
				} {
					sb.append(".");
				} sb.append(".") sb.append sb "." sb.append("#") sb.append sb "#" System.out.println(sb) System.out.println System.out System System.out sb sb.append("\n") sb.append sb "\n" sb=new StringBuilder("#") sb new StringBuilder("#") for (int c=1;c<b;c++){
				sb.append("#");
			} int c=1; int c=1; c 1 c<b c b c++ c++ c {
				sb.append("#");
			} {
				sb.append("#");
			} sb.append("#") sb.append sb "#" sb.append("\n") sb.append sb "\n" System.out.println(sb) System.out.println System.out System System.out sb a=n.nextInt() a n.nextInt() n.nextInt n b=n.nextInt() b n.nextInt() n.nextInt n sb=new StringBuilder("") sb new StringBuilder("") String[] args args public class Main {
	public static void main(String[] args) {
		StringBuilder sb=new StringBuilder("");
		Scanner n=new Scanner(System.in);
		int a=n.nextInt();
		int b=n.nextInt();
		while (a!=0 || b!=0){
			for (int c=0;c<b;c++){
					sb.append("#");
			}
			System.out.println(sb);
			sb.append("\n");//改行
			sb=new StringBuilder("#");
			for (int d=2;d<a;d++){
				for (int e=2;e<b;e++){
					sb.append(".");
				}
				sb.append("#");
				System.out.println(sb);
				sb.append("\n");//改行
				sb=new StringBuilder("#");
			}
			for (int c=1;c<b;c++){
				sb.append("#");
			}
		sb.append("\n");//改行
		System.out.println(sb);
		a=n.nextInt();b=n.nextInt();
		sb=new StringBuilder("");
		}
	}
} public class Main {
	public static void main(String[] args) {
		StringBuilder sb=new StringBuilder("");
		Scanner n=new Scanner(System.in);
		int a=n.nextInt();
		int b=n.nextInt();
		while (a!=0 || b!=0){
			for (int c=0;c<b;c++){
					sb.append("#");
			}
			System.out.println(sb);
			sb.append("\n");//改行
			sb=new StringBuilder("#");
			for (int d=2;d<a;d++){
				for (int e=2;e<b;e++){
					sb.append(".");
				}
				sb.append("#");
				System.out.println(sb);
				sb.append("\n");//改行
				sb=new StringBuilder("#");
			}
			for (int c=1;c<b;c++){
				sb.append("#");
			}
		sb.append("\n");//改行
		System.out.println(sb);
		a=n.nextInt();b=n.nextInt();
		sb=new StringBuilder("");
		}
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		StringBuilder sb=new StringBuilder("");
		Scanner n=new Scanner(System.in);
		int a=n.nextInt();
		int b=n.nextInt();
		while (a!=0 || b!=0){
			for (int c=0;c<b;c++){
					sb.append("#");
			}
			System.out.println(sb);
			sb.append("\n");//改行
			sb=new StringBuilder("#");
			for (int d=2;d<a;d++){
				for (int e=2;e<b;e++){
					sb.append(".");
				}
				sb.append("#");
				System.out.println(sb);
				sb.append("\n");//改行
				sb=new StringBuilder("#");
			}
			for (int c=1;c<b;c++){
				sb.append("#");
			}
		sb.append("\n");//改行
		System.out.println(sb);
		a=n.nextInt();b=n.nextInt();
		sb=new StringBuilder("");
		}
	}
}