import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Diagram diagram = new Diagram();
		try (Scanner stdin = new Scanner(System.in)) {
			int h, w;
			while (stdin.hasNext()) {
				h = Integer.parseInt(stdin.next());
				w = Integer.parseInt(stdin.next());
				if (h < 0 || h > 300 || w < 0 || w > 300) {
					throw new RuntimeException("Input Error:Range 0 to 300");
				}
				if (h == 0 && w == 0) {
					break;
				}
				diagram.draw(h, w);
				System.out.println("");
			}
		} catch (RuntimeException e) {
			e.printStackTrace();
		}
	}
}

abstract class AbstractDiagram {
	abstract void draw(int height, int width);
}

class Diagram extends AbstractDiagram {
	//
	@Override
	void draw(int h, int w) {
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				if ((i == 1 || i == h) || (j == 1 || j == w)) {
					sb.append('#');
				} else {
					sb.append('.');
				}
			}
			System.out.println(sb);
			sb.setLength(0); // sb clear
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Diagram diagram = new Diagram();
		try (Scanner stdin = new Scanner(System.in)) {
			int h, w;
			while (stdin.hasNext()) {
				h = Integer.parseInt(stdin.next());
				w = Integer.parseInt(stdin.next());
				if (h < 0 || h > 300 || w < 0 || w > 300) {
					throw new RuntimeException("Input Error:Range 0 to 300");
				}
				if (h == 0 && w == 0) {
					break;
				}
				diagram.draw(h, w);
				System.out.println("");
			}
		} catch (RuntimeException e) {
			e.printStackTrace();
		}
	}
} Main public static void main(String[] args) {
		Diagram diagram = new Diagram();
		try (Scanner stdin = new Scanner(System.in)) {
			int h, w;
			while (stdin.hasNext()) {
				h = Integer.parseInt(stdin.next());
				w = Integer.parseInt(stdin.next());
				if (h < 0 || h > 300 || w < 0 || w > 300) {
					throw new RuntimeException("Input Error:Range 0 to 300");
				}
				if (h == 0 && w == 0) {
					break;
				}
				diagram.draw(h, w);
				System.out.println("");
			}
		} catch (RuntimeException e) {
			e.printStackTrace();
		}
	} main {
		Diagram diagram = new Diagram();
		try (Scanner stdin = new Scanner(System.in)) {
			int h, w;
			while (stdin.hasNext()) {
				h = Integer.parseInt(stdin.next());
				w = Integer.parseInt(stdin.next());
				if (h < 0 || h > 300 || w < 0 || w > 300) {
					throw new RuntimeException("Input Error:Range 0 to 300");
				}
				if (h == 0 && w == 0) {
					break;
				}
				diagram.draw(h, w);
				System.out.println("");
			}
		} catch (RuntimeException e) {
			e.printStackTrace();
		}
	} Diagram diagram = new Diagram(); diagram new Diagram() try (Scanner stdin = new Scanner(System.in)) {
			int h, w;
			while (stdin.hasNext()) {
				h = Integer.parseInt(stdin.next());
				w = Integer.parseInt(stdin.next());
				if (h < 0 || h > 300 || w < 0 || w > 300) {
					throw new RuntimeException("Input Error:Range 0 to 300");
				}
				if (h == 0 && w == 0) {
					break;
				}
				diagram.draw(h, w);
				System.out.println("");
			}
		} catch (RuntimeException e) {
			e.printStackTrace();
		} catch (RuntimeException e) {
			e.printStackTrace();
		} RuntimeException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			int h, w;
			while (stdin.hasNext()) {
				h = Integer.parseInt(stdin.next());
				w = Integer.parseInt(stdin.next());
				if (h < 0 || h > 300 || w < 0 || w > 300) {
					throw new RuntimeException("Input Error:Range 0 to 300");
				}
				if (h == 0 && w == 0) {
					break;
				}
				diagram.draw(h, w);
				System.out.println("");
			}
		} Scanner stdin = new Scanner(System.in) Scanner stdin = new Scanner(System.in) new Scanner(System.in) int h h w; w while (stdin.hasNext()) {
				h = Integer.parseInt(stdin.next());
				w = Integer.parseInt(stdin.next());
				if (h < 0 || h > 300 || w < 0 || w > 300) {
					throw new RuntimeException("Input Error:Range 0 to 300");
				}
				if (h == 0 && w == 0) {
					break;
				}
				diagram.draw(h, w);
				System.out.println("");
			} stdin.hasNext() stdin.hasNext stdin {
				h = Integer.parseInt(stdin.next());
				w = Integer.parseInt(stdin.next());
				if (h < 0 || h > 300 || w < 0 || w > 300) {
					throw new RuntimeException("Input Error:Range 0 to 300");
				}
				if (h == 0 && w == 0) {
					break;
				}
				diagram.draw(h, w);
				System.out.println("");
			} h = Integer.parseInt(stdin.next()) h Integer.parseInt(stdin.next()) Integer.parseInt Integer stdin.next() stdin.next stdin w = Integer.parseInt(stdin.next()) w Integer.parseInt(stdin.next()) Integer.parseInt Integer stdin.next() stdin.next stdin if (h < 0 || h > 300 || w < 0 || w > 300) {
					throw new RuntimeException("Input Error:Range 0 to 300");
				} h < 0 || h > 300 || w < 0 || w > 300 w < 0 h < 0 || h > 300 || w < 0 || w > 300 h < 0 h 0 h > 300 h 300 w < 0 w 0 w > 300 w 300 {
					throw new RuntimeException("Input Error:Range 0 to 300");
				} throw new RuntimeException("Input Error:Range 0 to 300"); new RuntimeException("Input Error:Range 0 to 300") if (h == 0 && w == 0) {
					break;
				} h == 0 && w == 0 h == 0 h 0 w == 0 w 0 {
					break;
				} break; diagram.draw(h, w) diagram.draw diagram h w System.out.println("") System.out.println System.out System System.out "" String[] args args abstract class AbstractDiagram {
	abstract void draw(int height, int width);
} AbstractDiagram abstract void draw(int height, int width); draw int height height int width width class Diagram extends AbstractDiagram {
	//
	@Override
	void draw(int h, int w) {
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				if ((i == 1 || i == h) || (j == 1 || j == w)) {
					sb.append('#');
				} else {
					sb.append('.');
				}
			}
			System.out.println(sb);
			sb.setLength(0); // sb clear
		}
	}
} Diagram //
	@Override
	void draw(int h, int w) {
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				if ((i == 1 || i == h) || (j == 1 || j == w)) {
					sb.append('#');
				} else {
					sb.append('.');
				}
			}
			System.out.println(sb);
			sb.setLength(0); // sb clear
		}
	} draw {
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				if ((i == 1 || i == h) || (j == 1 || j == w)) {
					sb.append('#');
				} else {
					sb.append('.');
				}
			}
			System.out.println(sb);
			sb.setLength(0); // sb clear
		}
	} StringBuilder sb = new StringBuilder(); sb new StringBuilder() for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				if ((i == 1 || i == h) || (j == 1 || j == w)) {
					sb.append('#');
				} else {
					sb.append('.');
				}
			}
			System.out.println(sb);
			sb.setLength(0); // sb clear
		} int i = 1; int i = 1; i 1 i <= h i h i++ i++ i {
			for (int j = 1; j <= w; j++) {
				if ((i == 1 || i == h) || (j == 1 || j == w)) {
					sb.append('#');
				} else {
					sb.append('.');
				}
			}
			System.out.println(sb);
			sb.setLength(0); // sb clear
		} {
			for (int j = 1; j <= w; j++) {
				if ((i == 1 || i == h) || (j == 1 || j == w)) {
					sb.append('#');
				} else {
					sb.append('.');
				}
			}
			System.out.println(sb);
			sb.setLength(0); // sb clear
		} for (int j = 1; j <= w; j++) {
				if ((i == 1 || i == h) || (j == 1 || j == w)) {
					sb.append('#');
				} else {
					sb.append('.');
				}
			} int j = 1; int j = 1; j 1 j <= w j w j++ j++ j {
				if ((i == 1 || i == h) || (j == 1 || j == w)) {
					sb.append('#');
				} else {
					sb.append('.');
				}
			} {
				if ((i == 1 || i == h) || (j == 1 || j == w)) {
					sb.append('#');
				} else {
					sb.append('.');
				}
			} if ((i == 1 || i == h) || (j == 1 || j == w)) {
					sb.append('#');
				} else {
					sb.append('.');
				} (i == 1 || i == h) || (j == 1 || j == w) (i == 1 || i == h) i == 1 i 1 i == h i h (j == 1 || j == w) j == 1 j 1 j == w j w {
					sb.append('#');
				} sb.append('#') sb.append sb '#' {
					sb.append('.');
				} sb.append('.') sb.append sb '.' System.out.println(sb) System.out.println System.out System System.out sb sb.setLength(0) sb.setLength sb 0 int h h int w w AbstractDiagram public class Main {
	public static void main(String[] args) {
		Diagram diagram = new Diagram();
		try (Scanner stdin = new Scanner(System.in)) {
			int h, w;
			while (stdin.hasNext()) {
				h = Integer.parseInt(stdin.next());
				w = Integer.parseInt(stdin.next());
				if (h < 0 || h > 300 || w < 0 || w > 300) {
					throw new RuntimeException("Input Error:Range 0 to 300");
				}
				if (h == 0 && w == 0) {
					break;
				}
				diagram.draw(h, w);
				System.out.println("");
			}
		} catch (RuntimeException e) {
			e.printStackTrace();
		}
	}
} public class Main {
	public static void main(String[] args) {
		Diagram diagram = new Diagram();
		try (Scanner stdin = new Scanner(System.in)) {
			int h, w;
			while (stdin.hasNext()) {
				h = Integer.parseInt(stdin.next());
				w = Integer.parseInt(stdin.next());
				if (h < 0 || h > 300 || w < 0 || w > 300) {
					throw new RuntimeException("Input Error:Range 0 to 300");
				}
				if (h == 0 && w == 0) {
					break;
				}
				diagram.draw(h, w);
				System.out.println("");
			}
		} catch (RuntimeException e) {
			e.printStackTrace();
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Diagram diagram = new Diagram();
		try (Scanner stdin = new Scanner(System.in)) {
			int h, w;
			while (stdin.hasNext()) {
				h = Integer.parseInt(stdin.next());
				w = Integer.parseInt(stdin.next());
				if (h < 0 || h > 300 || w < 0 || w > 300) {
					throw new RuntimeException("Input Error:Range 0 to 300");
				}
				if (h == 0 && w == 0) {
					break;
				}
				diagram.draw(h, w);
				System.out.println("");
			}
		} catch (RuntimeException e) {
			e.printStackTrace();
		}
	}
}

abstract class AbstractDiagram {
	abstract void draw(int height, int width);
}

class Diagram extends AbstractDiagram {
	//
	@Override
	void draw(int h, int w) {
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				if ((i == 1 || i == h) || (j == 1 || j == w)) {
					sb.append('#');
				} else {
					sb.append('.');
				}
			}
			System.out.println(sb);
			sb.setLength(0); // sb clear
		}
	}
}