import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
		String s;
		int inCnt = 0;
		while ((s = stdIn.readLine()) != null) {
			inCnt++;
			String[] se = s.split(" ");
			int h = Integer.valueOf(se[0]);
			int w = Integer.valueOf(se[1]);
			if (h == 0 && w == 0)
				break;
			doMain(inCnt, h, w);
		}
		System.exit(0);
	}

	private static void doMain(int inCnt, int h, int w) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++)
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
					System.out.print("#");
				else
					System.out.print(".");
			System.out.println("");
		}
		System.out.println("");
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
		String s;
		int inCnt = 0;
		while ((s = stdIn.readLine()) != null) {
			inCnt++;
			String[] se = s.split(" ");
			int h = Integer.valueOf(se[0]);
			int w = Integer.valueOf(se[1]);
			if (h == 0 && w == 0)
				break;
			doMain(inCnt, h, w);
		}
		System.exit(0);
	}

	private static void doMain(int inCnt, int h, int w) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++)
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
					System.out.print("#");
				else
					System.out.print(".");
			System.out.println("");
		}
		System.out.println("");
	}
} Main public static void main(String[] args) throws Exception {
		BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
		String s;
		int inCnt = 0;
		while ((s = stdIn.readLine()) != null) {
			inCnt++;
			String[] se = s.split(" ");
			int h = Integer.valueOf(se[0]);
			int w = Integer.valueOf(se[1]);
			if (h == 0 && w == 0)
				break;
			doMain(inCnt, h, w);
		}
		System.exit(0);
	} main {
		BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
		String s;
		int inCnt = 0;
		while ((s = stdIn.readLine()) != null) {
			inCnt++;
			String[] se = s.split(" ");
			int h = Integer.valueOf(se[0]);
			int w = Integer.valueOf(se[1]);
			if (h == 0 && w == 0)
				break;
			doMain(inCnt, h, w);
		}
		System.exit(0);
	} BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in)); stdIn new BufferedReader(new InputStreamReader(System.in)) String s; s int inCnt = 0; inCnt 0 while ((s = stdIn.readLine()) != null) {
			inCnt++;
			String[] se = s.split(" ");
			int h = Integer.valueOf(se[0]);
			int w = Integer.valueOf(se[1]);
			if (h == 0 && w == 0)
				break;
			doMain(inCnt, h, w);
		} (s = stdIn.readLine()) != null (s = stdIn.readLine()) s stdIn.readLine() stdIn.readLine stdIn null {
			inCnt++;
			String[] se = s.split(" ");
			int h = Integer.valueOf(se[0]);
			int w = Integer.valueOf(se[1]);
			if (h == 0 && w == 0)
				break;
			doMain(inCnt, h, w);
		} inCnt++ inCnt String[] se = s.split(" "); se s.split(" ") s.split s " " int h = Integer.valueOf(se[0]); h Integer.valueOf(se[0]) Integer.valueOf Integer se[0] se 0 int w = Integer.valueOf(se[1]); w Integer.valueOf(se[1]) Integer.valueOf Integer se[1] se 1 if (h == 0 && w == 0)
				break; h == 0 && w == 0 h == 0 h 0 w == 0 w 0 break; doMain(inCnt, h, w) doMain inCnt h w System.exit(0) System.exit System 0 String[] args args private static void doMain(int inCnt, int h, int w) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++)
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
					System.out.print("#");
				else
					System.out.print(".");
			System.out.println("");
		}
		System.out.println("");
	} doMain {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++)
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
					System.out.print("#");
				else
					System.out.print(".");
			System.out.println("");
		}
		System.out.println("");
	} for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++)
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
					System.out.print("#");
				else
					System.out.print(".");
			System.out.println("");
		} int i = 0; int i = 0; i 0 i < h i h i++ i++ i {
			for (int j = 0; j < w; j++)
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
					System.out.print("#");
				else
					System.out.print(".");
			System.out.println("");
		} {
			for (int j = 0; j < w; j++)
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
					System.out.print("#");
				else
					System.out.print(".");
			System.out.println("");
		} for (int j = 0; j < w; j++)
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
					System.out.print("#");
				else
					System.out.print("."); int j = 0; int j = 0; j 0 j < w j w j++ j++ j if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
					System.out.print("#");
				else
					System.out.print("."); if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
					System.out.print("#");
				else
					System.out.print("."); i == 0 || i == h - 1 || j == 0 || j == w - 1 j == 0 i == 0 || i == h - 1 || j == 0 || j == w - 1 i == 0 i 0 i == h - 1 i h - 1 h 1 j == 0 j 0 j == w - 1 j w - 1 w 1 System.out.print("#") System.out.print System.out System System.out "#" 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 "" int inCnt inCnt int h h int w w public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
		String s;
		int inCnt = 0;
		while ((s = stdIn.readLine()) != null) {
			inCnt++;
			String[] se = s.split(" ");
			int h = Integer.valueOf(se[0]);
			int w = Integer.valueOf(se[1]);
			if (h == 0 && w == 0)
				break;
			doMain(inCnt, h, w);
		}
		System.exit(0);
	}

	private static void doMain(int inCnt, int h, int w) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++)
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
					System.out.print("#");
				else
					System.out.print(".");
			System.out.println("");
		}
		System.out.println("");
	}
} public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
		String s;
		int inCnt = 0;
		while ((s = stdIn.readLine()) != null) {
			inCnt++;
			String[] se = s.split(" ");
			int h = Integer.valueOf(se[0]);
			int w = Integer.valueOf(se[1]);
			if (h == 0 && w == 0)
				break;
			doMain(inCnt, h, w);
		}
		System.exit(0);
	}

	private static void doMain(int inCnt, int h, int w) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++)
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
					System.out.print("#");
				else
					System.out.print(".");
			System.out.println("");
		}
		System.out.println("");
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
		String s;
		int inCnt = 0;
		while ((s = stdIn.readLine()) != null) {
			inCnt++;
			String[] se = s.split(" ");
			int h = Integer.valueOf(se[0]);
			int w = Integer.valueOf(se[1]);
			if (h == 0 && w == 0)
				break;
			doMain(inCnt, h, w);
		}
		System.exit(0);
	}

	private static void doMain(int inCnt, int h, int w) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++)
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
					System.out.print("#");
				else
					System.out.print(".");
			System.out.println("");
		}
		System.out.println("");
	}
}