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

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int in = 0;

		while (true) {
			String string = new String();
			string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}

			lines.add(string);
			in++;
		}

		for (int i = 0; i < in; i++) {
			int h = 0;
			int w = 0;
			int v = 0;
			String[] str = lines.get(i).split(" ");
			h = Integer.parseInt(str[0]);
			w = Integer.parseInt(str[1]);
			v = w;

			StringBuilder str01 = new StringBuilder();
			StringBuilder str02 = new StringBuilder();

			while (w > 0) {
				str01.append("#");
				w--;
			}

			w = v;

			str02.append("#");
			while (w - 2 > 0) {
				str02.append(".");
				w--;
			}
			str02.append("#");

			System.out.println(str01);
			while (h - 2 > 0) {
				System.out.println(str02);
				h--;
			}
			System.out.println(str01);
			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) {
		// TODO ?????????????????????????????????????????????

		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int in = 0;

		while (true) {
			String string = new String();
			string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}

			lines.add(string);
			in++;
		}

		for (int i = 0; i < in; i++) {
			int h = 0;
			int w = 0;
			int v = 0;
			String[] str = lines.get(i).split(" ");
			h = Integer.parseInt(str[0]);
			w = Integer.parseInt(str[1]);
			v = w;

			StringBuilder str01 = new StringBuilder();
			StringBuilder str02 = new StringBuilder();

			while (w > 0) {
				str01.append("#");
				w--;
			}

			w = v;

			str02.append("#");
			while (w - 2 > 0) {
				str02.append(".");
				w--;
			}
			str02.append("#");

			System.out.println(str01);
			while (h - 2 > 0) {
				System.out.println(str02);
				h--;
			}
			System.out.println(str01);
			System.out.println("");
		}
	}
} Main public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int in = 0;

		while (true) {
			String string = new String();
			string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}

			lines.add(string);
			in++;
		}

		for (int i = 0; i < in; i++) {
			int h = 0;
			int w = 0;
			int v = 0;
			String[] str = lines.get(i).split(" ");
			h = Integer.parseInt(str[0]);
			w = Integer.parseInt(str[1]);
			v = w;

			StringBuilder str01 = new StringBuilder();
			StringBuilder str02 = new StringBuilder();

			while (w > 0) {
				str01.append("#");
				w--;
			}

			w = v;

			str02.append("#");
			while (w - 2 > 0) {
				str02.append(".");
				w--;
			}
			str02.append("#");

			System.out.println(str01);
			while (h - 2 > 0) {
				System.out.println(str02);
				h--;
			}
			System.out.println(str01);
			System.out.println("");
		}
	} main {
		// TODO ?????????????????????????????????????????????

		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int in = 0;

		while (true) {
			String string = new String();
			string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}

			lines.add(string);
			in++;
		}

		for (int i = 0; i < in; i++) {
			int h = 0;
			int w = 0;
			int v = 0;
			String[] str = lines.get(i).split(" ");
			h = Integer.parseInt(str[0]);
			w = Integer.parseInt(str[1]);
			v = w;

			StringBuilder str01 = new StringBuilder();
			StringBuilder str02 = new StringBuilder();

			while (w > 0) {
				str01.append("#");
				w--;
			}

			w = v;

			str02.append("#");
			while (w - 2 > 0) {
				str02.append(".");
				w--;
			}
			str02.append("#");

			System.out.println(str01);
			while (h - 2 > 0) {
				System.out.println(str02);
				h--;
			}
			System.out.println(str01);
			System.out.println("");
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) ArrayList<String> lines = new ArrayList<String>(); lines new ArrayList<String>() int in = 0; in 0 while (true) {
			String string = new String();
			string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}

			lines.add(string);
			in++;
		} true {
			String string = new String();
			string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}

			lines.add(string);
			in++;
		} String string = new String(); string new String() string = sc.nextLine() string sc.nextLine() sc.nextLine sc if (string.equals("0 0")) {
				break;
			} string.equals("0 0") string.equals string "0 0" {
				break;
			} break; lines.add(string) lines.add lines string in++ in for (int i = 0; i < in; i++) {
			int h = 0;
			int w = 0;
			int v = 0;
			String[] str = lines.get(i).split(" ");
			h = Integer.parseInt(str[0]);
			w = Integer.parseInt(str[1]);
			v = w;

			StringBuilder str01 = new StringBuilder();
			StringBuilder str02 = new StringBuilder();

			while (w > 0) {
				str01.append("#");
				w--;
			}

			w = v;

			str02.append("#");
			while (w - 2 > 0) {
				str02.append(".");
				w--;
			}
			str02.append("#");

			System.out.println(str01);
			while (h - 2 > 0) {
				System.out.println(str02);
				h--;
			}
			System.out.println(str01);
			System.out.println("");
		} int i = 0; int i = 0; i 0 i < in i in i++ i++ i {
			int h = 0;
			int w = 0;
			int v = 0;
			String[] str = lines.get(i).split(" ");
			h = Integer.parseInt(str[0]);
			w = Integer.parseInt(str[1]);
			v = w;

			StringBuilder str01 = new StringBuilder();
			StringBuilder str02 = new StringBuilder();

			while (w > 0) {
				str01.append("#");
				w--;
			}

			w = v;

			str02.append("#");
			while (w - 2 > 0) {
				str02.append(".");
				w--;
			}
			str02.append("#");

			System.out.println(str01);
			while (h - 2 > 0) {
				System.out.println(str02);
				h--;
			}
			System.out.println(str01);
			System.out.println("");
		} {
			int h = 0;
			int w = 0;
			int v = 0;
			String[] str = lines.get(i).split(" ");
			h = Integer.parseInt(str[0]);
			w = Integer.parseInt(str[1]);
			v = w;

			StringBuilder str01 = new StringBuilder();
			StringBuilder str02 = new StringBuilder();

			while (w > 0) {
				str01.append("#");
				w--;
			}

			w = v;

			str02.append("#");
			while (w - 2 > 0) {
				str02.append(".");
				w--;
			}
			str02.append("#");

			System.out.println(str01);
			while (h - 2 > 0) {
				System.out.println(str02);
				h--;
			}
			System.out.println(str01);
			System.out.println("");
		} int h = 0; h 0 int w = 0; w 0 int v = 0; v 0 String[] str = lines.get(i).split(" "); str lines.get(i).split(" ") lines.get(i).split lines.get(i) lines.get lines i " " h = Integer.parseInt(str[0]) h Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 w = Integer.parseInt(str[1]) w Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 v = w v w StringBuilder str01 = new StringBuilder(); str01 new StringBuilder() StringBuilder str02 = new StringBuilder(); str02 new StringBuilder() while (w > 0) {
				str01.append("#");
				w--;
			} w > 0 w 0 {
				str01.append("#");
				w--;
			} str01.append("#") str01.append str01 "#" w-- w w = v w v str02.append("#") str02.append str02 "#" while (w - 2 > 0) {
				str02.append(".");
				w--;
			} w - 2 > 0 w - 2 w 2 0 {
				str02.append(".");
				w--;
			} str02.append(".") str02.append str02 "." w-- w str02.append("#") str02.append str02 "#" System.out.println(str01) System.out.println System.out System System.out str01 while (h - 2 > 0) {
				System.out.println(str02);
				h--;
			} h - 2 > 0 h - 2 h 2 0 {
				System.out.println(str02);
				h--;
			} System.out.println(str02) System.out.println System.out System System.out str02 h-- h System.out.println(str01) System.out.println System.out System System.out str01 System.out.println("") System.out.println System.out System System.out "" String[] args args public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int in = 0;

		while (true) {
			String string = new String();
			string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}

			lines.add(string);
			in++;
		}

		for (int i = 0; i < in; i++) {
			int h = 0;
			int w = 0;
			int v = 0;
			String[] str = lines.get(i).split(" ");
			h = Integer.parseInt(str[0]);
			w = Integer.parseInt(str[1]);
			v = w;

			StringBuilder str01 = new StringBuilder();
			StringBuilder str02 = new StringBuilder();

			while (w > 0) {
				str01.append("#");
				w--;
			}

			w = v;

			str02.append("#");
			while (w - 2 > 0) {
				str02.append(".");
				w--;
			}
			str02.append("#");

			System.out.println(str01);
			while (h - 2 > 0) {
				System.out.println(str02);
				h--;
			}
			System.out.println(str01);
			System.out.println("");
		}
	}
} public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int in = 0;

		while (true) {
			String string = new String();
			string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}

			lines.add(string);
			in++;
		}

		for (int i = 0; i < in; i++) {
			int h = 0;
			int w = 0;
			int v = 0;
			String[] str = lines.get(i).split(" ");
			h = Integer.parseInt(str[0]);
			w = Integer.parseInt(str[1]);
			v = w;

			StringBuilder str01 = new StringBuilder();
			StringBuilder str02 = new StringBuilder();

			while (w > 0) {
				str01.append("#");
				w--;
			}

			w = v;

			str02.append("#");
			while (w - 2 > 0) {
				str02.append(".");
				w--;
			}
			str02.append("#");

			System.out.println(str01);
			while (h - 2 > 0) {
				System.out.println(str02);
				h--;
			}
			System.out.println(str01);
			System.out.println("");
		}
	}
} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int in = 0;

		while (true) {
			String string = new String();
			string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}

			lines.add(string);
			in++;
		}

		for (int i = 0; i < in; i++) {
			int h = 0;
			int w = 0;
			int v = 0;
			String[] str = lines.get(i).split(" ");
			h = Integer.parseInt(str[0]);
			w = Integer.parseInt(str[1]);
			v = w;

			StringBuilder str01 = new StringBuilder();
			StringBuilder str02 = new StringBuilder();

			while (w > 0) {
				str01.append("#");
				w--;
			}

			w = v;

			str02.append("#");
			while (w - 2 > 0) {
				str02.append(".");
				w--;
			}
			str02.append("#");

			System.out.println(str01);
			while (h - 2 > 0) {
				System.out.println(str02);
				h--;
			}
			System.out.println(str01);
			System.out.println("");
		}
	}
}