import java.util.*;
import java.lang.StringBuilder;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		StringBuilder bu = new StringBuilder();
		int h,w;
		while((h=sc.nextInt())!=0&&(w=sc.nextInt())!=0){
			for(int i=1;i<=h;i++){
				for(int o=1;o<=w;o++){
					if(i==1||o==1||i==h||o==w){
						bu.append("#");
					}else{
						bu.append(".");
					}
				}
				bu.append("\n");
			}
			bu.append("\n");
		}
		System.out.print(bu);
	}
} import java.util.*; util.* java import java.lang.StringBuilder; StringBuilder java.lang public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		StringBuilder bu = new StringBuilder();
		int h,w;
		while((h=sc.nextInt())!=0&&(w=sc.nextInt())!=0){
			for(int i=1;i<=h;i++){
				for(int o=1;o<=w;o++){
					if(i==1||o==1||i==h||o==w){
						bu.append("#");
					}else{
						bu.append(".");
					}
				}
				bu.append("\n");
			}
			bu.append("\n");
		}
		System.out.print(bu);
	}
} Main public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		StringBuilder bu = new StringBuilder();
		int h,w;
		while((h=sc.nextInt())!=0&&(w=sc.nextInt())!=0){
			for(int i=1;i<=h;i++){
				for(int o=1;o<=w;o++){
					if(i==1||o==1||i==h||o==w){
						bu.append("#");
					}else{
						bu.append(".");
					}
				}
				bu.append("\n");
			}
			bu.append("\n");
		}
		System.out.print(bu);
	} main {
		Scanner sc = new Scanner(System.in);
		StringBuilder bu = new StringBuilder();
		int h,w;
		while((h=sc.nextInt())!=0&&(w=sc.nextInt())!=0){
			for(int i=1;i<=h;i++){
				for(int o=1;o<=w;o++){
					if(i==1||o==1||i==h||o==w){
						bu.append("#");
					}else{
						bu.append(".");
					}
				}
				bu.append("\n");
			}
			bu.append("\n");
		}
		System.out.print(bu);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) StringBuilder bu = new StringBuilder(); bu new StringBuilder() int h h w; w while((h=sc.nextInt())!=0&&(w=sc.nextInt())!=0){
			for(int i=1;i<=h;i++){
				for(int o=1;o<=w;o++){
					if(i==1||o==1||i==h||o==w){
						bu.append("#");
					}else{
						bu.append(".");
					}
				}
				bu.append("\n");
			}
			bu.append("\n");
		} (h=sc.nextInt())!=0&&(w=sc.nextInt())!=0 (h=sc.nextInt())!=0 (h=sc.nextInt()) h sc.nextInt() sc.nextInt sc 0 (w=sc.nextInt())!=0 (w=sc.nextInt()) w sc.nextInt() sc.nextInt sc 0 {
			for(int i=1;i<=h;i++){
				for(int o=1;o<=w;o++){
					if(i==1||o==1||i==h||o==w){
						bu.append("#");
					}else{
						bu.append(".");
					}
				}
				bu.append("\n");
			}
			bu.append("\n");
		} for(int i=1;i<=h;i++){
				for(int o=1;o<=w;o++){
					if(i==1||o==1||i==h||o==w){
						bu.append("#");
					}else{
						bu.append(".");
					}
				}
				bu.append("\n");
			} int i=1; int i=1; i 1 i<=h i h i++ i++ i {
				for(int o=1;o<=w;o++){
					if(i==1||o==1||i==h||o==w){
						bu.append("#");
					}else{
						bu.append(".");
					}
				}
				bu.append("\n");
			} {
				for(int o=1;o<=w;o++){
					if(i==1||o==1||i==h||o==w){
						bu.append("#");
					}else{
						bu.append(".");
					}
				}
				bu.append("\n");
			} for(int o=1;o<=w;o++){
					if(i==1||o==1||i==h||o==w){
						bu.append("#");
					}else{
						bu.append(".");
					}
				} int o=1; int o=1; o 1 o<=w o w o++ o++ o {
					if(i==1||o==1||i==h||o==w){
						bu.append("#");
					}else{
						bu.append(".");
					}
				} {
					if(i==1||o==1||i==h||o==w){
						bu.append("#");
					}else{
						bu.append(".");
					}
				} if(i==1||o==1||i==h||o==w){
						bu.append("#");
					}else{
						bu.append(".");
					} i==1||o==1||i==h||o==w i==h i==1||o==1||i==h||o==w i==1 i 1 o==1 o 1 i==h i h o==w o w {
						bu.append("#");
					} bu.append("#") bu.append bu "#" {
						bu.append(".");
					} bu.append(".") bu.append bu "." bu.append("\n") bu.append bu "\n" bu.append("\n") bu.append bu "\n" System.out.print(bu) System.out.print System.out System System.out bu String[] args args public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		StringBuilder bu = new StringBuilder();
		int h,w;
		while((h=sc.nextInt())!=0&&(w=sc.nextInt())!=0){
			for(int i=1;i<=h;i++){
				for(int o=1;o<=w;o++){
					if(i==1||o==1||i==h||o==w){
						bu.append("#");
					}else{
						bu.append(".");
					}
				}
				bu.append("\n");
			}
			bu.append("\n");
		}
		System.out.print(bu);
	}
} public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		StringBuilder bu = new StringBuilder();
		int h,w;
		while((h=sc.nextInt())!=0&&(w=sc.nextInt())!=0){
			for(int i=1;i<=h;i++){
				for(int o=1;o<=w;o++){
					if(i==1||o==1||i==h||o==w){
						bu.append("#");
					}else{
						bu.append(".");
					}
				}
				bu.append("\n");
			}
			bu.append("\n");
		}
		System.out.print(bu);
	}
} Main
import java.util.*;
import java.lang.StringBuilder;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		StringBuilder bu = new StringBuilder();
		int h,w;
		while((h=sc.nextInt())!=0&&(w=sc.nextInt())!=0){
			for(int i=1;i<=h;i++){
				for(int o=1;o<=w;o++){
					if(i==1||o==1||i==h||o==w){
						bu.append("#");
					}else{
						bu.append(".");
					}
				}
				bu.append("\n");
			}
			bu.append("\n");
		}
		System.out.print(bu);
	}
}