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

public class Main {
	public static void main(String[] args) {
		int H, W, a = 0, cnt = 0;
		ArrayList<Integer> h = new ArrayList<Integer>();
		ArrayList<Integer> w = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		while(a < 300){
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0)
				break;
			h.add(new Integer(H));
			w.add(new Integer(W));
			a++;
		}
		for(cnt = 0; a > cnt; cnt++){
			if(cnt != 0)
				System.out.print("\n");
			for(int i = 0; i != h.get(new Integer(cnt)); i++){
				for(int j = 0; j != w.get(new Integer(cnt)); j++){
					if(i == 0 || i == h.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else if(j == 0 || j == w.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.print("\n");
			}
		}
		System.out.print("\n");
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		int H, W, a = 0, cnt = 0;
		ArrayList<Integer> h = new ArrayList<Integer>();
		ArrayList<Integer> w = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		while(a < 300){
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0)
				break;
			h.add(new Integer(H));
			w.add(new Integer(W));
			a++;
		}
		for(cnt = 0; a > cnt; cnt++){
			if(cnt != 0)
				System.out.print("\n");
			for(int i = 0; i != h.get(new Integer(cnt)); i++){
				for(int j = 0; j != w.get(new Integer(cnt)); j++){
					if(i == 0 || i == h.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else if(j == 0 || j == w.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.print("\n");
			}
		}
		System.out.print("\n");
	}
} Main public static void main(String[] args) {
		int H, W, a = 0, cnt = 0;
		ArrayList<Integer> h = new ArrayList<Integer>();
		ArrayList<Integer> w = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		while(a < 300){
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0)
				break;
			h.add(new Integer(H));
			w.add(new Integer(W));
			a++;
		}
		for(cnt = 0; a > cnt; cnt++){
			if(cnt != 0)
				System.out.print("\n");
			for(int i = 0; i != h.get(new Integer(cnt)); i++){
				for(int j = 0; j != w.get(new Integer(cnt)); j++){
					if(i == 0 || i == h.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else if(j == 0 || j == w.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.print("\n");
			}
		}
		System.out.print("\n");
	} main {
		int H, W, a = 0, cnt = 0;
		ArrayList<Integer> h = new ArrayList<Integer>();
		ArrayList<Integer> w = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		while(a < 300){
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0)
				break;
			h.add(new Integer(H));
			w.add(new Integer(W));
			a++;
		}
		for(cnt = 0; a > cnt; cnt++){
			if(cnt != 0)
				System.out.print("\n");
			for(int i = 0; i != h.get(new Integer(cnt)); i++){
				for(int j = 0; j != w.get(new Integer(cnt)); j++){
					if(i == 0 || i == h.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else if(j == 0 || j == w.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.print("\n");
			}
		}
		System.out.print("\n");
	} int H H W W a = 0 a 0 cnt = 0; cnt 0 ArrayList<Integer> h = new ArrayList<Integer>(); h new ArrayList<Integer>() ArrayList<Integer> w = new ArrayList<Integer>(); w new ArrayList<Integer>() Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(a < 300){
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0)
				break;
			h.add(new Integer(H));
			w.add(new Integer(W));
			a++;
		} a < 300 a 300 {
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0)
				break;
			h.add(new Integer(H));
			w.add(new Integer(W));
			a++;
		} H = sc.nextInt() H sc.nextInt() sc.nextInt sc W = sc.nextInt() W sc.nextInt() sc.nextInt sc if(H == 0 && W == 0)
				break; H == 0 && W == 0 H == 0 H 0 W == 0 W 0 break; h.add(new Integer(H)) h.add h new Integer(H) w.add(new Integer(W)) w.add w new Integer(W) a++ a for(cnt = 0; a > cnt; cnt++){
			if(cnt != 0)
				System.out.print("\n");
			for(int i = 0; i != h.get(new Integer(cnt)); i++){
				for(int j = 0; j != w.get(new Integer(cnt)); j++){
					if(i == 0 || i == h.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else if(j == 0 || j == w.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.print("\n");
			}
		} cnt = 0; cnt = 0 cnt 0 a > cnt a cnt cnt++ cnt++ cnt {
			if(cnt != 0)
				System.out.print("\n");
			for(int i = 0; i != h.get(new Integer(cnt)); i++){
				for(int j = 0; j != w.get(new Integer(cnt)); j++){
					if(i == 0 || i == h.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else if(j == 0 || j == w.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.print("\n");
			}
		} {
			if(cnt != 0)
				System.out.print("\n");
			for(int i = 0; i != h.get(new Integer(cnt)); i++){
				for(int j = 0; j != w.get(new Integer(cnt)); j++){
					if(i == 0 || i == h.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else if(j == 0 || j == w.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.print("\n");
			}
		} if(cnt != 0)
				System.out.print("\n"); cnt != 0 cnt 0 System.out.print("\n") System.out.print System.out System System.out "\n" for(int i = 0; i != h.get(new Integer(cnt)); i++){
				for(int j = 0; j != w.get(new Integer(cnt)); j++){
					if(i == 0 || i == h.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else if(j == 0 || j == w.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.print("\n");
			} int i = 0; int i = 0; i 0 i != h.get(new Integer(cnt)) i h.get(new Integer(cnt)) h.get h new Integer(cnt) i++ i++ i {
				for(int j = 0; j != w.get(new Integer(cnt)); j++){
					if(i == 0 || i == h.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else if(j == 0 || j == w.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.print("\n");
			} {
				for(int j = 0; j != w.get(new Integer(cnt)); j++){
					if(i == 0 || i == h.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else if(j == 0 || j == w.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.print("\n");
			} for(int j = 0; j != w.get(new Integer(cnt)); j++){
					if(i == 0 || i == h.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else if(j == 0 || j == w.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else
						System.out.print(".");
				} int j = 0; int j = 0; j 0 j != w.get(new Integer(cnt)) j w.get(new Integer(cnt)) w.get w new Integer(cnt) j++ j++ j {
					if(i == 0 || i == h.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else if(j == 0 || j == w.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else
						System.out.print(".");
				} {
					if(i == 0 || i == h.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else if(j == 0 || j == w.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else
						System.out.print(".");
				} if(i == 0 || i == h.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else if(j == 0 || j == w.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else
						System.out.print("."); i == 0 || i == h.get(new Integer(cnt)) - 1 i == 0 i 0 i == h.get(new Integer(cnt)) - 1 i h.get(new Integer(cnt)) - 1 h.get(new Integer(cnt)) h.get h new Integer(cnt) 1 System.out.print("#") System.out.print System.out System System.out "#" if(j == 0 || j == w.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else
						System.out.print("."); j == 0 || j == w.get(new Integer(cnt)) - 1 j == 0 j 0 j == w.get(new Integer(cnt)) - 1 j w.get(new Integer(cnt)) - 1 w.get(new Integer(cnt)) w.get w new Integer(cnt) 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.print("\n") System.out.print System.out System System.out "\n" System.out.print("\n") System.out.print System.out System System.out "\n" String[] args args public class Main {
	public static void main(String[] args) {
		int H, W, a = 0, cnt = 0;
		ArrayList<Integer> h = new ArrayList<Integer>();
		ArrayList<Integer> w = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		while(a < 300){
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0)
				break;
			h.add(new Integer(H));
			w.add(new Integer(W));
			a++;
		}
		for(cnt = 0; a > cnt; cnt++){
			if(cnt != 0)
				System.out.print("\n");
			for(int i = 0; i != h.get(new Integer(cnt)); i++){
				for(int j = 0; j != w.get(new Integer(cnt)); j++){
					if(i == 0 || i == h.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else if(j == 0 || j == w.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.print("\n");
			}
		}
		System.out.print("\n");
	}
} public class Main {
	public static void main(String[] args) {
		int H, W, a = 0, cnt = 0;
		ArrayList<Integer> h = new ArrayList<Integer>();
		ArrayList<Integer> w = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		while(a < 300){
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0)
				break;
			h.add(new Integer(H));
			w.add(new Integer(W));
			a++;
		}
		for(cnt = 0; a > cnt; cnt++){
			if(cnt != 0)
				System.out.print("\n");
			for(int i = 0; i != h.get(new Integer(cnt)); i++){
				for(int j = 0; j != w.get(new Integer(cnt)); j++){
					if(i == 0 || i == h.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else if(j == 0 || j == w.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.print("\n");
			}
		}
		System.out.print("\n");
	}
} Main

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

public class Main {
	public static void main(String[] args) {
		int H, W, a = 0, cnt = 0;
		ArrayList<Integer> h = new ArrayList<Integer>();
		ArrayList<Integer> w = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		while(a < 300){
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0)
				break;
			h.add(new Integer(H));
			w.add(new Integer(W));
			a++;
		}
		for(cnt = 0; a > cnt; cnt++){
			if(cnt != 0)
				System.out.print("\n");
			for(int i = 0; i != h.get(new Integer(cnt)); i++){
				for(int j = 0; j != w.get(new Integer(cnt)); j++){
					if(i == 0 || i == h.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else if(j == 0 || j == w.get(new Integer(cnt)) - 1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.print("\n");
			}
		}
		System.out.print("\n");
	}
}