import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException{
		InputReader in = new InputReader(System.in);
		
		while (true) {
			int height = in.readInt();
			int width = in.readInt();
			if (height == 0 && width == 0) break;
			
			StringBuffer sBuffer = new StringBuffer(width);
			StringBuffer sBufferWithDot = new StringBuffer(width);
			for (int j = 0; j < width; j++) {
				sBuffer.append("#");
				
				if (j == 0 || j == width - 1) {
					sBufferWithDot.append("#");
				}else {
					sBufferWithDot.append(".");
				}
			}
			
			
			for (int i = 0; i < height; i++) {
				if(i == 0 || i == height - 1) {
					System.out.println(sBuffer.toString());
				}else {
					System.out.println(sBufferWithDot.toString());
				}
				
			}
			System.out.println();
		}
	}
}

class InputReader{
	private BufferedReader br;
	private StringTokenizer buffer = null;	
	
	public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));				
	}

	public String read() throws IOException {
		while(buffer == null || !buffer.hasMoreTokens()) {
			buffer = new StringTokenizer(br.readLine());
		}
		return buffer.nextToken();
	}
	
	public int readInt() throws IOException {
		while(buffer == null || !buffer.hasMoreTokens()) {
			buffer = new StringTokenizer(br.readLine());
		}
		return Integer.parseInt(buffer.nextToken());
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util public class Main {
	public static void main(String[] args) throws IOException{
		InputReader in = new InputReader(System.in);
		
		while (true) {
			int height = in.readInt();
			int width = in.readInt();
			if (height == 0 && width == 0) break;
			
			StringBuffer sBuffer = new StringBuffer(width);
			StringBuffer sBufferWithDot = new StringBuffer(width);
			for (int j = 0; j < width; j++) {
				sBuffer.append("#");
				
				if (j == 0 || j == width - 1) {
					sBufferWithDot.append("#");
				}else {
					sBufferWithDot.append(".");
				}
			}
			
			
			for (int i = 0; i < height; i++) {
				if(i == 0 || i == height - 1) {
					System.out.println(sBuffer.toString());
				}else {
					System.out.println(sBufferWithDot.toString());
				}
				
			}
			System.out.println();
		}
	}
} Main public static void main(String[] args) throws IOException{
		InputReader in = new InputReader(System.in);
		
		while (true) {
			int height = in.readInt();
			int width = in.readInt();
			if (height == 0 && width == 0) break;
			
			StringBuffer sBuffer = new StringBuffer(width);
			StringBuffer sBufferWithDot = new StringBuffer(width);
			for (int j = 0; j < width; j++) {
				sBuffer.append("#");
				
				if (j == 0 || j == width - 1) {
					sBufferWithDot.append("#");
				}else {
					sBufferWithDot.append(".");
				}
			}
			
			
			for (int i = 0; i < height; i++) {
				if(i == 0 || i == height - 1) {
					System.out.println(sBuffer.toString());
				}else {
					System.out.println(sBufferWithDot.toString());
				}
				
			}
			System.out.println();
		}
	} main {
		InputReader in = new InputReader(System.in);
		
		while (true) {
			int height = in.readInt();
			int width = in.readInt();
			if (height == 0 && width == 0) break;
			
			StringBuffer sBuffer = new StringBuffer(width);
			StringBuffer sBufferWithDot = new StringBuffer(width);
			for (int j = 0; j < width; j++) {
				sBuffer.append("#");
				
				if (j == 0 || j == width - 1) {
					sBufferWithDot.append("#");
				}else {
					sBufferWithDot.append(".");
				}
			}
			
			
			for (int i = 0; i < height; i++) {
				if(i == 0 || i == height - 1) {
					System.out.println(sBuffer.toString());
				}else {
					System.out.println(sBufferWithDot.toString());
				}
				
			}
			System.out.println();
		}
	} InputReader in = new InputReader(System.in); in new InputReader(System.in) while (true) {
			int height = in.readInt();
			int width = in.readInt();
			if (height == 0 && width == 0) break;
			
			StringBuffer sBuffer = new StringBuffer(width);
			StringBuffer sBufferWithDot = new StringBuffer(width);
			for (int j = 0; j < width; j++) {
				sBuffer.append("#");
				
				if (j == 0 || j == width - 1) {
					sBufferWithDot.append("#");
				}else {
					sBufferWithDot.append(".");
				}
			}
			
			
			for (int i = 0; i < height; i++) {
				if(i == 0 || i == height - 1) {
					System.out.println(sBuffer.toString());
				}else {
					System.out.println(sBufferWithDot.toString());
				}
				
			}
			System.out.println();
		} true {
			int height = in.readInt();
			int width = in.readInt();
			if (height == 0 && width == 0) break;
			
			StringBuffer sBuffer = new StringBuffer(width);
			StringBuffer sBufferWithDot = new StringBuffer(width);
			for (int j = 0; j < width; j++) {
				sBuffer.append("#");
				
				if (j == 0 || j == width - 1) {
					sBufferWithDot.append("#");
				}else {
					sBufferWithDot.append(".");
				}
			}
			
			
			for (int i = 0; i < height; i++) {
				if(i == 0 || i == height - 1) {
					System.out.println(sBuffer.toString());
				}else {
					System.out.println(sBufferWithDot.toString());
				}
				
			}
			System.out.println();
		} int height = in.readInt(); height in.readInt() in.readInt in int width = in.readInt(); width in.readInt() in.readInt in if (height == 0 && width == 0) break; height == 0 && width == 0 height == 0 height 0 width == 0 width 0 break; StringBuffer sBuffer = new StringBuffer(width); sBuffer new StringBuffer(width) StringBuffer sBufferWithDot = new StringBuffer(width); sBufferWithDot new StringBuffer(width) for (int j = 0; j < width; j++) {
				sBuffer.append("#");
				
				if (j == 0 || j == width - 1) {
					sBufferWithDot.append("#");
				}else {
					sBufferWithDot.append(".");
				}
			} int j = 0; int j = 0; j 0 j < width j width j++ j++ j {
				sBuffer.append("#");
				
				if (j == 0 || j == width - 1) {
					sBufferWithDot.append("#");
				}else {
					sBufferWithDot.append(".");
				}
			} {
				sBuffer.append("#");
				
				if (j == 0 || j == width - 1) {
					sBufferWithDot.append("#");
				}else {
					sBufferWithDot.append(".");
				}
			} sBuffer.append("#") sBuffer.append sBuffer "#" if (j == 0 || j == width - 1) {
					sBufferWithDot.append("#");
				}else {
					sBufferWithDot.append(".");
				} j == 0 || j == width - 1 j == 0 j 0 j == width - 1 j width - 1 width 1 {
					sBufferWithDot.append("#");
				} sBufferWithDot.append("#") sBufferWithDot.append sBufferWithDot "#" {
					sBufferWithDot.append(".");
				} sBufferWithDot.append(".") sBufferWithDot.append sBufferWithDot "." for (int i = 0; i < height; i++) {
				if(i == 0 || i == height - 1) {
					System.out.println(sBuffer.toString());
				}else {
					System.out.println(sBufferWithDot.toString());
				}
				
			} int i = 0; int i = 0; i 0 i < height i height i++ i++ i {
				if(i == 0 || i == height - 1) {
					System.out.println(sBuffer.toString());
				}else {
					System.out.println(sBufferWithDot.toString());
				}
				
			} {
				if(i == 0 || i == height - 1) {
					System.out.println(sBuffer.toString());
				}else {
					System.out.println(sBufferWithDot.toString());
				}
				
			} if(i == 0 || i == height - 1) {
					System.out.println(sBuffer.toString());
				}else {
					System.out.println(sBufferWithDot.toString());
				} i == 0 || i == height - 1 i == 0 i 0 i == height - 1 i height - 1 height 1 {
					System.out.println(sBuffer.toString());
				} System.out.println(sBuffer.toString()) System.out.println System.out System System.out sBuffer.toString() sBuffer.toString sBuffer {
					System.out.println(sBufferWithDot.toString());
				} System.out.println(sBufferWithDot.toString()) System.out.println System.out System System.out sBufferWithDot.toString() sBufferWithDot.toString sBufferWithDot System.out.println() System.out.println System.out System System.out String[] args args class InputReader{
	private BufferedReader br;
	private StringTokenizer buffer = null;	
	
	public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));				
	}

	public String read() throws IOException {
		while(buffer == null || !buffer.hasMoreTokens()) {
			buffer = new StringTokenizer(br.readLine());
		}
		return buffer.nextToken();
	}
	
	public int readInt() throws IOException {
		while(buffer == null || !buffer.hasMoreTokens()) {
			buffer = new StringTokenizer(br.readLine());
		}
		return Integer.parseInt(buffer.nextToken());
	}
} InputReader private BufferedReader br; br private StringTokenizer buffer = null; buffer null public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));				
	} InputReader {
		br = new BufferedReader(new InputStreamReader(in));				
	} br = new BufferedReader(new InputStreamReader(in)) br new BufferedReader(new InputStreamReader(in)) InputStream in in public String read() throws IOException {
		while(buffer == null || !buffer.hasMoreTokens()) {
			buffer = new StringTokenizer(br.readLine());
		}
		return buffer.nextToken();
	} read {
		while(buffer == null || !buffer.hasMoreTokens()) {
			buffer = new StringTokenizer(br.readLine());
		}
		return buffer.nextToken();
	} while(buffer == null || !buffer.hasMoreTokens()) {
			buffer = new StringTokenizer(br.readLine());
		} buffer == null || !buffer.hasMoreTokens() buffer == null buffer null !buffer.hasMoreTokens() buffer.hasMoreTokens() buffer.hasMoreTokens buffer {
			buffer = new StringTokenizer(br.readLine());
		} buffer = new StringTokenizer(br.readLine()) buffer new StringTokenizer(br.readLine()) return buffer.nextToken(); buffer.nextToken() buffer.nextToken buffer public int readInt() throws IOException {
		while(buffer == null || !buffer.hasMoreTokens()) {
			buffer = new StringTokenizer(br.readLine());
		}
		return Integer.parseInt(buffer.nextToken());
	} readInt {
		while(buffer == null || !buffer.hasMoreTokens()) {
			buffer = new StringTokenizer(br.readLine());
		}
		return Integer.parseInt(buffer.nextToken());
	} while(buffer == null || !buffer.hasMoreTokens()) {
			buffer = new StringTokenizer(br.readLine());
		} buffer == null || !buffer.hasMoreTokens() buffer == null buffer null !buffer.hasMoreTokens() buffer.hasMoreTokens() buffer.hasMoreTokens buffer {
			buffer = new StringTokenizer(br.readLine());
		} buffer = new StringTokenizer(br.readLine()) buffer new StringTokenizer(br.readLine()) return Integer.parseInt(buffer.nextToken()); Integer.parseInt(buffer.nextToken()) Integer.parseInt Integer buffer.nextToken() buffer.nextToken buffer public class Main {
	public static void main(String[] args) throws IOException{
		InputReader in = new InputReader(System.in);
		
		while (true) {
			int height = in.readInt();
			int width = in.readInt();
			if (height == 0 && width == 0) break;
			
			StringBuffer sBuffer = new StringBuffer(width);
			StringBuffer sBufferWithDot = new StringBuffer(width);
			for (int j = 0; j < width; j++) {
				sBuffer.append("#");
				
				if (j == 0 || j == width - 1) {
					sBufferWithDot.append("#");
				}else {
					sBufferWithDot.append(".");
				}
			}
			
			
			for (int i = 0; i < height; i++) {
				if(i == 0 || i == height - 1) {
					System.out.println(sBuffer.toString());
				}else {
					System.out.println(sBufferWithDot.toString());
				}
				
			}
			System.out.println();
		}
	}
} public class Main {
	public static void main(String[] args) throws IOException{
		InputReader in = new InputReader(System.in);
		
		while (true) {
			int height = in.readInt();
			int width = in.readInt();
			if (height == 0 && width == 0) break;
			
			StringBuffer sBuffer = new StringBuffer(width);
			StringBuffer sBufferWithDot = new StringBuffer(width);
			for (int j = 0; j < width; j++) {
				sBuffer.append("#");
				
				if (j == 0 || j == width - 1) {
					sBufferWithDot.append("#");
				}else {
					sBufferWithDot.append(".");
				}
			}
			
			
			for (int i = 0; i < height; i++) {
				if(i == 0 || i == height - 1) {
					System.out.println(sBuffer.toString());
				}else {
					System.out.println(sBufferWithDot.toString());
				}
				
			}
			System.out.println();
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException{
		InputReader in = new InputReader(System.in);
		
		while (true) {
			int height = in.readInt();
			int width = in.readInt();
			if (height == 0 && width == 0) break;
			
			StringBuffer sBuffer = new StringBuffer(width);
			StringBuffer sBufferWithDot = new StringBuffer(width);
			for (int j = 0; j < width; j++) {
				sBuffer.append("#");
				
				if (j == 0 || j == width - 1) {
					sBufferWithDot.append("#");
				}else {
					sBufferWithDot.append(".");
				}
			}
			
			
			for (int i = 0; i < height; i++) {
				if(i == 0 || i == height - 1) {
					System.out.println(sBuffer.toString());
				}else {
					System.out.println(sBufferWithDot.toString());
				}
				
			}
			System.out.println();
		}
	}
}

class InputReader{
	private BufferedReader br;
	private StringTokenizer buffer = null;	
	
	public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));				
	}

	public String read() throws IOException {
		while(buffer == null || !buffer.hasMoreTokens()) {
			buffer = new StringTokenizer(br.readLine());
		}
		return buffer.nextToken();
	}
	
	public int readInt() throws IOException {
		while(buffer == null || !buffer.hasMoreTokens()) {
			buffer = new StringTokenizer(br.readLine());
		}
		return Integer.parseInt(buffer.nextToken());
	}
}
