import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner x = new Scanner(System.in);
		int h = x.nextInt();
		int w = x.nextInt();
		StringBuilder sb1 = new StringBuilder();
		while (h != 0 || w != 0){
			for (int i = 0 ; i < w ; i++ ){
				sb1.append("#");
			}
			int k = 0;
			sb1.append("\n");
			while (k < h-2){
			k++;
			sb1.append("#");
				for (int n = 0 ; n < w-2 ; n++){
				sb1.append(".");
				}
			sb1.append("#");
			sb1.append("\n");
			}

			for (int r = 0 ; r < w ; r++ ){
				sb1.append("#");
			}
			sb1.append("\n");
			sb1.append("\n");
			h = x.nextInt();
			w = x.nextInt();
		}
		System.out.print(sb1);
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner x = new Scanner(System.in);
		int h = x.nextInt();
		int w = x.nextInt();
		StringBuilder sb1 = new StringBuilder();
		while (h != 0 || w != 0){
			for (int i = 0 ; i < w ; i++ ){
				sb1.append("#");
			}
			int k = 0;
			sb1.append("\n");
			while (k < h-2){
			k++;
			sb1.append("#");
				for (int n = 0 ; n < w-2 ; n++){
				sb1.append(".");
				}
			sb1.append("#");
			sb1.append("\n");
			}

			for (int r = 0 ; r < w ; r++ ){
				sb1.append("#");
			}
			sb1.append("\n");
			sb1.append("\n");
			h = x.nextInt();
			w = x.nextInt();
		}
		System.out.print(sb1);
	}

} Main public static void main(String[] args) {
		Scanner x = new Scanner(System.in);
		int h = x.nextInt();
		int w = x.nextInt();
		StringBuilder sb1 = new StringBuilder();
		while (h != 0 || w != 0){
			for (int i = 0 ; i < w ; i++ ){
				sb1.append("#");
			}
			int k = 0;
			sb1.append("\n");
			while (k < h-2){
			k++;
			sb1.append("#");
				for (int n = 0 ; n < w-2 ; n++){
				sb1.append(".");
				}
			sb1.append("#");
			sb1.append("\n");
			}

			for (int r = 0 ; r < w ; r++ ){
				sb1.append("#");
			}
			sb1.append("\n");
			sb1.append("\n");
			h = x.nextInt();
			w = x.nextInt();
		}
		System.out.print(sb1);
	} main {
		Scanner x = new Scanner(System.in);
		int h = x.nextInt();
		int w = x.nextInt();
		StringBuilder sb1 = new StringBuilder();
		while (h != 0 || w != 0){
			for (int i = 0 ; i < w ; i++ ){
				sb1.append("#");
			}
			int k = 0;
			sb1.append("\n");
			while (k < h-2){
			k++;
			sb1.append("#");
				for (int n = 0 ; n < w-2 ; n++){
				sb1.append(".");
				}
			sb1.append("#");
			sb1.append("\n");
			}

			for (int r = 0 ; r < w ; r++ ){
				sb1.append("#");
			}
			sb1.append("\n");
			sb1.append("\n");
			h = x.nextInt();
			w = x.nextInt();
		}
		System.out.print(sb1);
	} Scanner x = new Scanner(System.in); x new Scanner(System.in) int h = x.nextInt(); h x.nextInt() x.nextInt x int w = x.nextInt(); w x.nextInt() x.nextInt x StringBuilder sb1 = new StringBuilder(); sb1 new StringBuilder() while (h != 0 || w != 0){
			for (int i = 0 ; i < w ; i++ ){
				sb1.append("#");
			}
			int k = 0;
			sb1.append("\n");
			while (k < h-2){
			k++;
			sb1.append("#");
				for (int n = 0 ; n < w-2 ; n++){
				sb1.append(".");
				}
			sb1.append("#");
			sb1.append("\n");
			}

			for (int r = 0 ; r < w ; r++ ){
				sb1.append("#");
			}
			sb1.append("\n");
			sb1.append("\n");
			h = x.nextInt();
			w = x.nextInt();
		} h != 0 || w != 0 h != 0 h 0 w != 0 w 0 {
			for (int i = 0 ; i < w ; i++ ){
				sb1.append("#");
			}
			int k = 0;
			sb1.append("\n");
			while (k < h-2){
			k++;
			sb1.append("#");
				for (int n = 0 ; n < w-2 ; n++){
				sb1.append(".");
				}
			sb1.append("#");
			sb1.append("\n");
			}

			for (int r = 0 ; r < w ; r++ ){
				sb1.append("#");
			}
			sb1.append("\n");
			sb1.append("\n");
			h = x.nextInt();
			w = x.nextInt();
		} for (int i = 0 ; i < w ; i++ ){
				sb1.append("#");
			} int i = 0 ; int i = 0 ; i 0 i < w i w i++ i++ i {
				sb1.append("#");
			} {
				sb1.append("#");
			} sb1.append("#") sb1.append sb1 "#" int k = 0; k 0 sb1.append("\n") sb1.append sb1 "\n" while (k < h-2){
			k++;
			sb1.append("#");
				for (int n = 0 ; n < w-2 ; n++){
				sb1.append(".");
				}
			sb1.append("#");
			sb1.append("\n");
			} k < h-2 k h-2 h 2 {
			k++;
			sb1.append("#");
				for (int n = 0 ; n < w-2 ; n++){
				sb1.append(".");
				}
			sb1.append("#");
			sb1.append("\n");
			} k++ k sb1.append("#") sb1.append sb1 "#" for (int n = 0 ; n < w-2 ; n++){
				sb1.append(".");
				} int n = 0 ; int n = 0 ; n 0 n < w-2 n w-2 w 2 n++ n++ n {
				sb1.append(".");
				} {
				sb1.append(".");
				} sb1.append(".") sb1.append sb1 "." sb1.append("#") sb1.append sb1 "#" sb1.append("\n") sb1.append sb1 "\n" for (int r = 0 ; r < w ; r++ ){
				sb1.append("#");
			} int r = 0 ; int r = 0 ; r 0 r < w r w r++ r++ r {
				sb1.append("#");
			} {
				sb1.append("#");
			} sb1.append("#") sb1.append sb1 "#" sb1.append("\n") sb1.append sb1 "\n" sb1.append("\n") sb1.append sb1 "\n" h = x.nextInt() h x.nextInt() x.nextInt x w = x.nextInt() w x.nextInt() x.nextInt x System.out.print(sb1) System.out.print System.out System System.out sb1 String[] args args public class Main {
	public static void main(String[] args) {
		Scanner x = new Scanner(System.in);
		int h = x.nextInt();
		int w = x.nextInt();
		StringBuilder sb1 = new StringBuilder();
		while (h != 0 || w != 0){
			for (int i = 0 ; i < w ; i++ ){
				sb1.append("#");
			}
			int k = 0;
			sb1.append("\n");
			while (k < h-2){
			k++;
			sb1.append("#");
				for (int n = 0 ; n < w-2 ; n++){
				sb1.append(".");
				}
			sb1.append("#");
			sb1.append("\n");
			}

			for (int r = 0 ; r < w ; r++ ){
				sb1.append("#");
			}
			sb1.append("\n");
			sb1.append("\n");
			h = x.nextInt();
			w = x.nextInt();
		}
		System.out.print(sb1);
	}

} public class Main {
	public static void main(String[] args) {
		Scanner x = new Scanner(System.in);
		int h = x.nextInt();
		int w = x.nextInt();
		StringBuilder sb1 = new StringBuilder();
		while (h != 0 || w != 0){
			for (int i = 0 ; i < w ; i++ ){
				sb1.append("#");
			}
			int k = 0;
			sb1.append("\n");
			while (k < h-2){
			k++;
			sb1.append("#");
				for (int n = 0 ; n < w-2 ; n++){
				sb1.append(".");
				}
			sb1.append("#");
			sb1.append("\n");
			}

			for (int r = 0 ; r < w ; r++ ){
				sb1.append("#");
			}
			sb1.append("\n");
			sb1.append("\n");
			h = x.nextInt();
			w = x.nextInt();
		}
		System.out.print(sb1);
	}

} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner x = new Scanner(System.in);
		int h = x.nextInt();
		int w = x.nextInt();
		StringBuilder sb1 = new StringBuilder();
		while (h != 0 || w != 0){
			for (int i = 0 ; i < w ; i++ ){
				sb1.append("#");
			}
			int k = 0;
			sb1.append("\n");
			while (k < h-2){
			k++;
			sb1.append("#");
				for (int n = 0 ; n < w-2 ; n++){
				sb1.append(".");
				}
			sb1.append("#");
			sb1.append("\n");
			}

			for (int r = 0 ; r < w ; r++ ){
				sb1.append("#");
			}
			sb1.append("\n");
			sb1.append("\n");
			h = x.nextInt();
			w = x.nextInt();
		}
		System.out.print(sb1);
	}

}