import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		char s='#',p='.',n='\n';
		while(true){
			String in=br.readLine();
			if(in.equals("0 0")) break;
			String[] a=in.split(" ");
			int H=Integer.parseInt(a[0]);
	        int W=Integer.parseInt(a[1]);
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					if(i!=0&&i!=H-1&&j!=0&&j!=W-1){
						sb.append(p);
					}else{
						sb.append(s);
					}
				}
				sb.append(n);
			}
			sb.append(n);
		}
		System.out.print(sb);
	}
} import java.io.*; io.* java class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		char s='#',p='.',n='\n';
		while(true){
			String in=br.readLine();
			if(in.equals("0 0")) break;
			String[] a=in.split(" ");
			int H=Integer.parseInt(a[0]);
	        int W=Integer.parseInt(a[1]);
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					if(i!=0&&i!=H-1&&j!=0&&j!=W-1){
						sb.append(p);
					}else{
						sb.append(s);
					}
				}
				sb.append(n);
			}
			sb.append(n);
		}
		System.out.print(sb);
	}
} Main public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		char s='#',p='.',n='\n';
		while(true){
			String in=br.readLine();
			if(in.equals("0 0")) break;
			String[] a=in.split(" ");
			int H=Integer.parseInt(a[0]);
	        int W=Integer.parseInt(a[1]);
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					if(i!=0&&i!=H-1&&j!=0&&j!=W-1){
						sb.append(p);
					}else{
						sb.append(s);
					}
				}
				sb.append(n);
			}
			sb.append(n);
		}
		System.out.print(sb);
	} main {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		char s='#',p='.',n='\n';
		while(true){
			String in=br.readLine();
			if(in.equals("0 0")) break;
			String[] a=in.split(" ");
			int H=Integer.parseInt(a[0]);
	        int W=Integer.parseInt(a[1]);
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					if(i!=0&&i!=H-1&&j!=0&&j!=W-1){
						sb.append(p);
					}else{
						sb.append(s);
					}
				}
				sb.append(n);
			}
			sb.append(n);
		}
		System.out.print(sb);
	} BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb=new StringBuilder(); sb new StringBuilder() char s='#' s '#' p='.' p '.' n='\n'; n '\n' while(true){
			String in=br.readLine();
			if(in.equals("0 0")) break;
			String[] a=in.split(" ");
			int H=Integer.parseInt(a[0]);
	        int W=Integer.parseInt(a[1]);
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					if(i!=0&&i!=H-1&&j!=0&&j!=W-1){
						sb.append(p);
					}else{
						sb.append(s);
					}
				}
				sb.append(n);
			}
			sb.append(n);
		} true {
			String in=br.readLine();
			if(in.equals("0 0")) break;
			String[] a=in.split(" ");
			int H=Integer.parseInt(a[0]);
	        int W=Integer.parseInt(a[1]);
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					if(i!=0&&i!=H-1&&j!=0&&j!=W-1){
						sb.append(p);
					}else{
						sb.append(s);
					}
				}
				sb.append(n);
			}
			sb.append(n);
		} String in=br.readLine(); in br.readLine() br.readLine br if(in.equals("0 0")) break; in.equals("0 0") in.equals in "0 0" break; String[] a=in.split(" "); a in.split(" ") in.split in " " int H=Integer.parseInt(a[0]); H Integer.parseInt(a[0]) Integer.parseInt Integer a[0] a 0 int W=Integer.parseInt(a[1]); W Integer.parseInt(a[1]) Integer.parseInt Integer a[1] a 1 for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					if(i!=0&&i!=H-1&&j!=0&&j!=W-1){
						sb.append(p);
					}else{
						sb.append(s);
					}
				}
				sb.append(n);
			} int i=0; int i=0; i 0 i<H i H i++ i++ i {
				for(int j=0;j<W;j++){
					if(i!=0&&i!=H-1&&j!=0&&j!=W-1){
						sb.append(p);
					}else{
						sb.append(s);
					}
				}
				sb.append(n);
			} {
				for(int j=0;j<W;j++){
					if(i!=0&&i!=H-1&&j!=0&&j!=W-1){
						sb.append(p);
					}else{
						sb.append(s);
					}
				}
				sb.append(n);
			} for(int j=0;j<W;j++){
					if(i!=0&&i!=H-1&&j!=0&&j!=W-1){
						sb.append(p);
					}else{
						sb.append(s);
					}
				} int j=0; int j=0; j 0 j<W j W j++ j++ j {
					if(i!=0&&i!=H-1&&j!=0&&j!=W-1){
						sb.append(p);
					}else{
						sb.append(s);
					}
				} {
					if(i!=0&&i!=H-1&&j!=0&&j!=W-1){
						sb.append(p);
					}else{
						sb.append(s);
					}
				} if(i!=0&&i!=H-1&&j!=0&&j!=W-1){
						sb.append(p);
					}else{
						sb.append(s);
					} i!=0&&i!=H-1&&j!=0&&j!=W-1 j!=0 i!=0&&i!=H-1&&j!=0&&j!=W-1 i!=0 i 0 i!=H-1 i H-1 H 1 j!=0 j 0 j!=W-1 j W-1 W 1 {
						sb.append(p);
					} sb.append(p) sb.append sb p {
						sb.append(s);
					} sb.append(s) sb.append sb s sb.append(n) sb.append sb n sb.append(n) sb.append sb n System.out.print(sb) System.out.print System.out System System.out sb String[] args args
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		char s='#',p='.',n='\n';
		while(true){
			String in=br.readLine();
			if(in.equals("0 0")) break;
			String[] a=in.split(" ");
			int H=Integer.parseInt(a[0]);
	        int W=Integer.parseInt(a[1]);
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					if(i!=0&&i!=H-1&&j!=0&&j!=W-1){
						sb.append(p);
					}else{
						sb.append(s);
					}
				}
				sb.append(n);
			}
			sb.append(n);
		}
		System.out.print(sb);
	}
}