import java.io.*;

class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String lns[] = br.readLine().split(" ");
			int ln[] = parseInts(lns);
			if(ln[0]==0 && ln[1]==0) break;
			for(int x=0; x<ln[0] ;x++){
				for(int y=0; y<ln[1]; y++){
					if(y==ln[1]-1){
						System.out.println("#");
					}else if(y==0 || x==0 || x==ln[0]-1){
						System.out.print("#");
					}else{
						System.out.print("#");
					}
				}
			}
			System.out.println();
		}
	}
	static int[] parseInts(String[] s){
		int[] x = new int[s.length];
		for(int i=0;i<s.length;i++){
			x[i] = Integer.parseInt(s[i]);
		}
		return x;
	}
} import java.io.*; io.* java class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String lns[] = br.readLine().split(" ");
			int ln[] = parseInts(lns);
			if(ln[0]==0 && ln[1]==0) break;
			for(int x=0; x<ln[0] ;x++){
				for(int y=0; y<ln[1]; y++){
					if(y==ln[1]-1){
						System.out.println("#");
					}else if(y==0 || x==0 || x==ln[0]-1){
						System.out.print("#");
					}else{
						System.out.print("#");
					}
				}
			}
			System.out.println();
		}
	}
	static int[] parseInts(String[] s){
		int[] x = new int[s.length];
		for(int i=0;i<s.length;i++){
			x[i] = Integer.parseInt(s[i]);
		}
		return x;
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String lns[] = br.readLine().split(" ");
			int ln[] = parseInts(lns);
			if(ln[0]==0 && ln[1]==0) break;
			for(int x=0; x<ln[0] ;x++){
				for(int y=0; y<ln[1]; y++){
					if(y==ln[1]-1){
						System.out.println("#");
					}else if(y==0 || x==0 || x==ln[0]-1){
						System.out.print("#");
					}else{
						System.out.print("#");
					}
				}
			}
			System.out.println();
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String lns[] = br.readLine().split(" ");
			int ln[] = parseInts(lns);
			if(ln[0]==0 && ln[1]==0) break;
			for(int x=0; x<ln[0] ;x++){
				for(int y=0; y<ln[1]; y++){
					if(y==ln[1]-1){
						System.out.println("#");
					}else if(y==0 || x==0 || x==ln[0]-1){
						System.out.print("#");
					}else{
						System.out.print("#");
					}
				}
			}
			System.out.println();
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
			String lns[] = br.readLine().split(" ");
			int ln[] = parseInts(lns);
			if(ln[0]==0 && ln[1]==0) break;
			for(int x=0; x<ln[0] ;x++){
				for(int y=0; y<ln[1]; y++){
					if(y==ln[1]-1){
						System.out.println("#");
					}else if(y==0 || x==0 || x==ln[0]-1){
						System.out.print("#");
					}else{
						System.out.print("#");
					}
				}
			}
			System.out.println();
		} true {
			String lns[] = br.readLine().split(" ");
			int ln[] = parseInts(lns);
			if(ln[0]==0 && ln[1]==0) break;
			for(int x=0; x<ln[0] ;x++){
				for(int y=0; y<ln[1]; y++){
					if(y==ln[1]-1){
						System.out.println("#");
					}else if(y==0 || x==0 || x==ln[0]-1){
						System.out.print("#");
					}else{
						System.out.print("#");
					}
				}
			}
			System.out.println();
		} String lns[] = br.readLine().split(" "); lns br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int ln[] = parseInts(lns); ln parseInts(lns) parseInts lns if(ln[0]==0 && ln[1]==0) break; ln[0]==0 && ln[1]==0 ln[0]==0 ln[0] ln 0 0 ln[1]==0 ln[1] ln 1 0 break; for(int x=0; x<ln[0] ;x++){
				for(int y=0; y<ln[1]; y++){
					if(y==ln[1]-1){
						System.out.println("#");
					}else if(y==0 || x==0 || x==ln[0]-1){
						System.out.print("#");
					}else{
						System.out.print("#");
					}
				}
			} int x=0; int x=0; x 0 x<ln[0] x ln[0] ln 0 x++ x++ x {
				for(int y=0; y<ln[1]; y++){
					if(y==ln[1]-1){
						System.out.println("#");
					}else if(y==0 || x==0 || x==ln[0]-1){
						System.out.print("#");
					}else{
						System.out.print("#");
					}
				}
			} {
				for(int y=0; y<ln[1]; y++){
					if(y==ln[1]-1){
						System.out.println("#");
					}else if(y==0 || x==0 || x==ln[0]-1){
						System.out.print("#");
					}else{
						System.out.print("#");
					}
				}
			} for(int y=0; y<ln[1]; y++){
					if(y==ln[1]-1){
						System.out.println("#");
					}else if(y==0 || x==0 || x==ln[0]-1){
						System.out.print("#");
					}else{
						System.out.print("#");
					}
				} int y=0; int y=0; y 0 y<ln[1] y ln[1] ln 1 y++ y++ y {
					if(y==ln[1]-1){
						System.out.println("#");
					}else if(y==0 || x==0 || x==ln[0]-1){
						System.out.print("#");
					}else{
						System.out.print("#");
					}
				} {
					if(y==ln[1]-1){
						System.out.println("#");
					}else if(y==0 || x==0 || x==ln[0]-1){
						System.out.print("#");
					}else{
						System.out.print("#");
					}
				} if(y==ln[1]-1){
						System.out.println("#");
					}else if(y==0 || x==0 || x==ln[0]-1){
						System.out.print("#");
					}else{
						System.out.print("#");
					} y==ln[1]-1 y ln[1]-1 ln[1] ln 1 1 {
						System.out.println("#");
					} System.out.println("#") System.out.println System.out System System.out "#" if(y==0 || x==0 || x==ln[0]-1){
						System.out.print("#");
					}else{
						System.out.print("#");
					} y==0 || x==0 || x==ln[0]-1 y==0 || x==0 || x==ln[0]-1 y==0 y 0 x==0 x 0 x==ln[0]-1 x ln[0]-1 ln[0] ln 0 1 {
						System.out.print("#");
					} System.out.print("#") System.out.print System.out System System.out "#" {
						System.out.print("#");
					} System.out.print("#") System.out.print System.out System System.out "#" System.out.println() System.out.println System.out System System.out String[] args args static int[] parseInts(String[] s){
		int[] x = new int[s.length];
		for(int i=0;i<s.length;i++){
			x[i] = Integer.parseInt(s[i]);
		}
		return x;
	} parseInts {
		int[] x = new int[s.length];
		for(int i=0;i<s.length;i++){
			x[i] = Integer.parseInt(s[i]);
		}
		return x;
	} int[] x = new int[s.length]; x new int[s.length] s.length s s.length for(int i=0;i<s.length;i++){
			x[i] = Integer.parseInt(s[i]);
		} int i=0; int i=0; i 0 i<s.length i s.length s s.length i++ i++ i {
			x[i] = Integer.parseInt(s[i]);
		} {
			x[i] = Integer.parseInt(s[i]);
		} x[i] = Integer.parseInt(s[i]) x[i] x i Integer.parseInt(s[i]) Integer.parseInt Integer s[i] s i return x; x String[] s s
import java.io.*;

class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String lns[] = br.readLine().split(" ");
			int ln[] = parseInts(lns);
			if(ln[0]==0 && ln[1]==0) break;
			for(int x=0; x<ln[0] ;x++){
				for(int y=0; y<ln[1]; y++){
					if(y==ln[1]-1){
						System.out.println("#");
					}else if(y==0 || x==0 || x==ln[0]-1){
						System.out.print("#");
					}else{
						System.out.print("#");
					}
				}
			}
			System.out.println();
		}
	}
	static int[] parseInts(String[] s){
		int[] x = new int[s.length];
		for(int i=0;i<s.length;i++){
			x[i] = Integer.parseInt(s[i]);
		}
		return x;
	}
}