import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		boolean flg = true;

		ArrayList<Integer> widthList = new ArrayList<Integer>();
		ArrayList<Integer> heightList = new ArrayList<Integer>();

		while (flg) {
			scanner.hasNext();
			int h = scanner.nextInt();
			int w = scanner.nextInt();

			if ((h == 0) && (w == 0)) {
				flg = false;
				break;
			}

			// Integer????????°??????????????????
			widthList.add(Integer.valueOf(w));
			heightList.add(Integer.valueOf(h));
		}

		for (int i = 0; i < widthList.size(); i++) {
			for (int k = 0; k < heightList.get(i); k++) {
				for (int j = 0; j < widthList.get(i); j++) {
					if (k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}

	}
} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		boolean flg = true;

		ArrayList<Integer> widthList = new ArrayList<Integer>();
		ArrayList<Integer> heightList = new ArrayList<Integer>();

		while (flg) {
			scanner.hasNext();
			int h = scanner.nextInt();
			int w = scanner.nextInt();

			if ((h == 0) && (w == 0)) {
				flg = false;
				break;
			}

			// Integer????????°??????????????????
			widthList.add(Integer.valueOf(w));
			heightList.add(Integer.valueOf(h));
		}

		for (int i = 0; i < widthList.size(); i++) {
			for (int k = 0; k < heightList.get(i); k++) {
				for (int j = 0; j < widthList.get(i); j++) {
					if (k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}

	}
} Main public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		boolean flg = true;

		ArrayList<Integer> widthList = new ArrayList<Integer>();
		ArrayList<Integer> heightList = new ArrayList<Integer>();

		while (flg) {
			scanner.hasNext();
			int h = scanner.nextInt();
			int w = scanner.nextInt();

			if ((h == 0) && (w == 0)) {
				flg = false;
				break;
			}

			// Integer????????°??????????????????
			widthList.add(Integer.valueOf(w));
			heightList.add(Integer.valueOf(h));
		}

		for (int i = 0; i < widthList.size(); i++) {
			for (int k = 0; k < heightList.get(i); k++) {
				for (int j = 0; j < widthList.get(i); j++) {
					if (k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}

	} main {

		Scanner scanner = new Scanner(System.in);

		boolean flg = true;

		ArrayList<Integer> widthList = new ArrayList<Integer>();
		ArrayList<Integer> heightList = new ArrayList<Integer>();

		while (flg) {
			scanner.hasNext();
			int h = scanner.nextInt();
			int w = scanner.nextInt();

			if ((h == 0) && (w == 0)) {
				flg = false;
				break;
			}

			// Integer????????°??????????????????
			widthList.add(Integer.valueOf(w));
			heightList.add(Integer.valueOf(h));
		}

		for (int i = 0; i < widthList.size(); i++) {
			for (int k = 0; k < heightList.get(i); k++) {
				for (int j = 0; j < widthList.get(i); j++) {
					if (k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}

	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) boolean flg = true; flg true ArrayList<Integer> widthList = new ArrayList<Integer>(); widthList new ArrayList<Integer>() ArrayList<Integer> heightList = new ArrayList<Integer>(); heightList new ArrayList<Integer>() while (flg) {
			scanner.hasNext();
			int h = scanner.nextInt();
			int w = scanner.nextInt();

			if ((h == 0) && (w == 0)) {
				flg = false;
				break;
			}

			// Integer????????°??????????????????
			widthList.add(Integer.valueOf(w));
			heightList.add(Integer.valueOf(h));
		} flg {
			scanner.hasNext();
			int h = scanner.nextInt();
			int w = scanner.nextInt();

			if ((h == 0) && (w == 0)) {
				flg = false;
				break;
			}

			// Integer????????°??????????????????
			widthList.add(Integer.valueOf(w));
			heightList.add(Integer.valueOf(h));
		} scanner.hasNext() scanner.hasNext scanner int h = scanner.nextInt(); h scanner.nextInt() scanner.nextInt scanner int w = scanner.nextInt(); w scanner.nextInt() scanner.nextInt scanner if ((h == 0) && (w == 0)) {
				flg = false;
				break;
			} (h == 0) && (w == 0) (h == 0) h 0 (w == 0) w 0 {
				flg = false;
				break;
			} flg = false flg false break; widthList.add(Integer.valueOf(w)) widthList.add widthList Integer.valueOf(w) Integer.valueOf Integer w heightList.add(Integer.valueOf(h)) heightList.add heightList Integer.valueOf(h) Integer.valueOf Integer h for (int i = 0; i < widthList.size(); i++) {
			for (int k = 0; k < heightList.get(i); k++) {
				for (int j = 0; j < widthList.get(i); j++) {
					if (k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		} int i = 0; int i = 0; i 0 i < widthList.size() i widthList.size() widthList.size widthList i++ i++ i {
			for (int k = 0; k < heightList.get(i); k++) {
				for (int j = 0; j < widthList.get(i); j++) {
					if (k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		} {
			for (int k = 0; k < heightList.get(i); k++) {
				for (int j = 0; j < widthList.get(i); j++) {
					if (k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		} for (int k = 0; k < heightList.get(i); k++) {
				for (int j = 0; j < widthList.get(i); j++) {
					if (k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			} int k = 0; int k = 0; k 0 k < heightList.get(i) k heightList.get(i) heightList.get heightList i k++ k++ k {
				for (int j = 0; j < widthList.get(i); j++) {
					if (k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			} {
				for (int j = 0; j < widthList.get(i); j++) {
					if (k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			} for (int j = 0; j < widthList.get(i); j++) {
					if (k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				} int j = 0; int j = 0; j 0 j < widthList.get(i) j widthList.get(i) widthList.get widthList i j++ j++ j {
					if (k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				} {
					if (k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				} if (k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					} k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1 j == 0 k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1 k == 0 k 0 k == heightList.get(i) - 1 k heightList.get(i) - 1 heightList.get(i) heightList.get heightList i 1 j == 0 j 0 j == widthList.get(i) - 1 j widthList.get(i) - 1 widthList.get(i) widthList.get widthList i 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 System.out.println() System.out.println System.out System System.out String[] args args public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		boolean flg = true;

		ArrayList<Integer> widthList = new ArrayList<Integer>();
		ArrayList<Integer> heightList = new ArrayList<Integer>();

		while (flg) {
			scanner.hasNext();
			int h = scanner.nextInt();
			int w = scanner.nextInt();

			if ((h == 0) && (w == 0)) {
				flg = false;
				break;
			}

			// Integer????????°??????????????????
			widthList.add(Integer.valueOf(w));
			heightList.add(Integer.valueOf(h));
		}

		for (int i = 0; i < widthList.size(); i++) {
			for (int k = 0; k < heightList.get(i); k++) {
				for (int j = 0; j < widthList.get(i); j++) {
					if (k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}

	}
} public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		boolean flg = true;

		ArrayList<Integer> widthList = new ArrayList<Integer>();
		ArrayList<Integer> heightList = new ArrayList<Integer>();

		while (flg) {
			scanner.hasNext();
			int h = scanner.nextInt();
			int w = scanner.nextInt();

			if ((h == 0) && (w == 0)) {
				flg = false;
				break;
			}

			// Integer????????°??????????????????
			widthList.add(Integer.valueOf(w));
			heightList.add(Integer.valueOf(h));
		}

		for (int i = 0; i < widthList.size(); i++) {
			for (int k = 0; k < heightList.get(i); k++) {
				for (int j = 0; j < widthList.get(i); j++) {
					if (k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}

	}
} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		boolean flg = true;

		ArrayList<Integer> widthList = new ArrayList<Integer>();
		ArrayList<Integer> heightList = new ArrayList<Integer>();

		while (flg) {
			scanner.hasNext();
			int h = scanner.nextInt();
			int w = scanner.nextInt();

			if ((h == 0) && (w == 0)) {
				flg = false;
				break;
			}

			// Integer????????°??????????????????
			widthList.add(Integer.valueOf(w));
			heightList.add(Integer.valueOf(h));
		}

		for (int i = 0; i < widthList.size(); i++) {
			for (int k = 0; k < heightList.get(i); k++) {
				for (int j = 0; j < widthList.get(i); j++) {
					if (k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}

	}
}