import java.util.Scanner;

class Main{
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		StringBuilder all = new StringBuilder();
		StringBuilder out = new StringBuilder();
		
		while(true){
			
			int h = sc.nextInt();
			int w = sc.nextInt();
			
			if((h + w) <= 0){break;}
			
			//top
			for(int t = 0; t < w; t++){
				out = out.append("#");
			}
			out = out.append("\n");
			
			//center
			
			for(int j = 0; j < (h-2); j++){
				out = out.append("#");
				for(int i = 0; i < (w-2); i++){
						out = out.append(".");
					}
				out = out.append("#");
				out = out.append("\n");
			}
			for(int b = 0; b < w; b++){
				out = out.append("#");
			}
			out = out.append("\n");
			
			all = all.append(out + "\n");
			out.delete(0, out.length());
			
		}
		
		System.out.print(all);
	}
} import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		StringBuilder all = new StringBuilder();
		StringBuilder out = new StringBuilder();
		
		while(true){
			
			int h = sc.nextInt();
			int w = sc.nextInt();
			
			if((h + w) <= 0){break;}
			
			//top
			for(int t = 0; t < w; t++){
				out = out.append("#");
			}
			out = out.append("\n");
			
			//center
			
			for(int j = 0; j < (h-2); j++){
				out = out.append("#");
				for(int i = 0; i < (w-2); i++){
						out = out.append(".");
					}
				out = out.append("#");
				out = out.append("\n");
			}
			for(int b = 0; b < w; b++){
				out = out.append("#");
			}
			out = out.append("\n");
			
			all = all.append(out + "\n");
			out.delete(0, out.length());
			
		}
		
		System.out.print(all);
	}
} Main public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		StringBuilder all = new StringBuilder();
		StringBuilder out = new StringBuilder();
		
		while(true){
			
			int h = sc.nextInt();
			int w = sc.nextInt();
			
			if((h + w) <= 0){break;}
			
			//top
			for(int t = 0; t < w; t++){
				out = out.append("#");
			}
			out = out.append("\n");
			
			//center
			
			for(int j = 0; j < (h-2); j++){
				out = out.append("#");
				for(int i = 0; i < (w-2); i++){
						out = out.append(".");
					}
				out = out.append("#");
				out = out.append("\n");
			}
			for(int b = 0; b < w; b++){
				out = out.append("#");
			}
			out = out.append("\n");
			
			all = all.append(out + "\n");
			out.delete(0, out.length());
			
		}
		
		System.out.print(all);
	} main {
		
		Scanner sc = new Scanner(System.in);
		
		StringBuilder all = new StringBuilder();
		StringBuilder out = new StringBuilder();
		
		while(true){
			
			int h = sc.nextInt();
			int w = sc.nextInt();
			
			if((h + w) <= 0){break;}
			
			//top
			for(int t = 0; t < w; t++){
				out = out.append("#");
			}
			out = out.append("\n");
			
			//center
			
			for(int j = 0; j < (h-2); j++){
				out = out.append("#");
				for(int i = 0; i < (w-2); i++){
						out = out.append(".");
					}
				out = out.append("#");
				out = out.append("\n");
			}
			for(int b = 0; b < w; b++){
				out = out.append("#");
			}
			out = out.append("\n");
			
			all = all.append(out + "\n");
			out.delete(0, out.length());
			
		}
		
		System.out.print(all);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) StringBuilder all = new StringBuilder(); all new StringBuilder() StringBuilder out = new StringBuilder(); out new StringBuilder() while(true){
			
			int h = sc.nextInt();
			int w = sc.nextInt();
			
			if((h + w) <= 0){break;}
			
			//top
			for(int t = 0; t < w; t++){
				out = out.append("#");
			}
			out = out.append("\n");
			
			//center
			
			for(int j = 0; j < (h-2); j++){
				out = out.append("#");
				for(int i = 0; i < (w-2); i++){
						out = out.append(".");
					}
				out = out.append("#");
				out = out.append("\n");
			}
			for(int b = 0; b < w; b++){
				out = out.append("#");
			}
			out = out.append("\n");
			
			all = all.append(out + "\n");
			out.delete(0, out.length());
			
		} true {
			
			int h = sc.nextInt();
			int w = sc.nextInt();
			
			if((h + w) <= 0){break;}
			
			//top
			for(int t = 0; t < w; t++){
				out = out.append("#");
			}
			out = out.append("\n");
			
			//center
			
			for(int j = 0; j < (h-2); j++){
				out = out.append("#");
				for(int i = 0; i < (w-2); i++){
						out = out.append(".");
					}
				out = out.append("#");
				out = out.append("\n");
			}
			for(int b = 0; b < w; b++){
				out = out.append("#");
			}
			out = out.append("\n");
			
			all = all.append(out + "\n");
			out.delete(0, out.length());
			
		} int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc int w = sc.nextInt(); w sc.nextInt() sc.nextInt sc if((h + w) <= 0){break;} (h + w) <= 0 (h + w) h w 0 {break;} break; for(int t = 0; t < w; t++){
				out = out.append("#");
			} int t = 0; int t = 0; t 0 t < w t w t++ t++ t {
				out = out.append("#");
			} {
				out = out.append("#");
			} out = out.append("#") out out.append("#") out.append out "#" out = out.append("\n") out out.append("\n") out.append out "\n" for(int j = 0; j < (h-2); j++){
				out = out.append("#");
				for(int i = 0; i < (w-2); i++){
						out = out.append(".");
					}
				out = out.append("#");
				out = out.append("\n");
			} int j = 0; int j = 0; j 0 j < (h-2) j (h-2) h 2 j++ j++ j {
				out = out.append("#");
				for(int i = 0; i < (w-2); i++){
						out = out.append(".");
					}
				out = out.append("#");
				out = out.append("\n");
			} {
				out = out.append("#");
				for(int i = 0; i < (w-2); i++){
						out = out.append(".");
					}
				out = out.append("#");
				out = out.append("\n");
			} out = out.append("#") out out.append("#") out.append out "#" for(int i = 0; i < (w-2); i++){
						out = out.append(".");
					} int i = 0; int i = 0; i 0 i < (w-2) i (w-2) w 2 i++ i++ i {
						out = out.append(".");
					} {
						out = out.append(".");
					} out = out.append(".") out out.append(".") out.append out "." out = out.append("#") out out.append("#") out.append out "#" out = out.append("\n") out out.append("\n") out.append out "\n" for(int b = 0; b < w; b++){
				out = out.append("#");
			} int b = 0; int b = 0; b 0 b < w b w b++ b++ b {
				out = out.append("#");
			} {
				out = out.append("#");
			} out = out.append("#") out out.append("#") out.append out "#" out = out.append("\n") out out.append("\n") out.append out "\n" all = all.append(out + "\n") all all.append(out + "\n") all.append all out + "\n" out "\n" out.delete(0, out.length()) out.delete out 0 out.length() out.length out System.out.print(all) System.out.print System.out System System.out all String[] args args
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		StringBuilder all = new StringBuilder();
		StringBuilder out = new StringBuilder();
		
		while(true){
			
			int h = sc.nextInt();
			int w = sc.nextInt();
			
			if((h + w) <= 0){break;}
			
			//top
			for(int t = 0; t < w; t++){
				out = out.append("#");
			}
			out = out.append("\n");
			
			//center
			
			for(int j = 0; j < (h-2); j++){
				out = out.append("#");
				for(int i = 0; i < (w-2); i++){
						out = out.append(".");
					}
				out = out.append("#");
				out = out.append("\n");
			}
			for(int b = 0; b < w; b++){
				out = out.append("#");
			}
			out = out.append("\n");
			
			all = all.append(out + "\n");
			out.delete(0, out.length());
			
		}
		
		System.out.print(all);
	}
}