import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0){
				break;
			}else{
				for(int i = 1; i <= H; i++){
					String str = "";
					for(int j = 1; j <= W; j++){
						if((i == 1 || i == H) || (j == 1 || j == W)){
							str += "#";
						}else{
							str += ".";
						}
					}
					System.out.println(str);
				}
				System.out.println();
			}
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0){
				break;
			}else{
				for(int i = 1; i <= H; i++){
					String str = "";
					for(int j = 1; j <= W; j++){
						if((i == 1 || i == H) || (j == 1 || j == W)){
							str += "#";
						}else{
							str += ".";
						}
					}
					System.out.println(str);
				}
				System.out.println();
			}
		}
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0){
				break;
			}else{
				for(int i = 1; i <= H; i++){
					String str = "";
					for(int j = 1; j <= W; j++){
						if((i == 1 || i == H) || (j == 1 || j == W)){
							str += "#";
						}else{
							str += ".";
						}
					}
					System.out.println(str);
				}
				System.out.println();
			}
		}
	} main {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0){
				break;
			}else{
				for(int i = 1; i <= H; i++){
					String str = "";
					for(int j = 1; j <= W; j++){
						if((i == 1 || i == H) || (j == 1 || j == W)){
							str += "#";
						}else{
							str += ".";
						}
					}
					System.out.println(str);
				}
				System.out.println();
			}
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while(scan.hasNext()){
			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0){
				break;
			}else{
				for(int i = 1; i <= H; i++){
					String str = "";
					for(int j = 1; j <= W; j++){
						if((i == 1 || i == H) || (j == 1 || j == W)){
							str += "#";
						}else{
							str += ".";
						}
					}
					System.out.println(str);
				}
				System.out.println();
			}
		} scan.hasNext() scan.hasNext scan {
			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0){
				break;
			}else{
				for(int i = 1; i <= H; i++){
					String str = "";
					for(int j = 1; j <= W; j++){
						if((i == 1 || i == H) || (j == 1 || j == W)){
							str += "#";
						}else{
							str += ".";
						}
					}
					System.out.println(str);
				}
				System.out.println();
			}
		} int H = scan.nextInt(); H scan.nextInt() scan.nextInt scan int W = scan.nextInt(); W scan.nextInt() scan.nextInt scan if(H == 0 && W == 0){
				break;
			}else{
				for(int i = 1; i <= H; i++){
					String str = "";
					for(int j = 1; j <= W; j++){
						if((i == 1 || i == H) || (j == 1 || j == W)){
							str += "#";
						}else{
							str += ".";
						}
					}
					System.out.println(str);
				}
				System.out.println();
			} H == 0 && W == 0 H == 0 H 0 W == 0 W 0 {
				break;
			} break; {
				for(int i = 1; i <= H; i++){
					String str = "";
					for(int j = 1; j <= W; j++){
						if((i == 1 || i == H) || (j == 1 || j == W)){
							str += "#";
						}else{
							str += ".";
						}
					}
					System.out.println(str);
				}
				System.out.println();
			} for(int i = 1; i <= H; i++){
					String str = "";
					for(int j = 1; j <= W; j++){
						if((i == 1 || i == H) || (j == 1 || j == W)){
							str += "#";
						}else{
							str += ".";
						}
					}
					System.out.println(str);
				} int i = 1; int i = 1; i 1 i <= H i H i++ i++ i {
					String str = "";
					for(int j = 1; j <= W; j++){
						if((i == 1 || i == H) || (j == 1 || j == W)){
							str += "#";
						}else{
							str += ".";
						}
					}
					System.out.println(str);
				} {
					String str = "";
					for(int j = 1; j <= W; j++){
						if((i == 1 || i == H) || (j == 1 || j == W)){
							str += "#";
						}else{
							str += ".";
						}
					}
					System.out.println(str);
				} String str = ""; str "" for(int j = 1; j <= W; j++){
						if((i == 1 || i == H) || (j == 1 || j == W)){
							str += "#";
						}else{
							str += ".";
						}
					} int j = 1; int j = 1; j 1 j <= W j W j++ j++ j {
						if((i == 1 || i == H) || (j == 1 || j == W)){
							str += "#";
						}else{
							str += ".";
						}
					} {
						if((i == 1 || i == H) || (j == 1 || j == W)){
							str += "#";
						}else{
							str += ".";
						}
					} if((i == 1 || i == H) || (j == 1 || j == W)){
							str += "#";
						}else{
							str += ".";
						} (i == 1 || i == H) || (j == 1 || j == W) (i == 1 || i == H) i == 1 i 1 i == H i H (j == 1 || j == W) j == 1 j 1 j == W j W {
							str += "#";
						} str += "#" str "#" {
							str += ".";
						} str += "." str "." System.out.println(str) System.out.println System.out System System.out str System.out.println() System.out.println System.out System System.out String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0){
				break;
			}else{
				for(int i = 1; i <= H; i++){
					String str = "";
					for(int j = 1; j <= W; j++){
						if((i == 1 || i == H) || (j == 1 || j == W)){
							str += "#";
						}else{
							str += ".";
						}
					}
					System.out.println(str);
				}
				System.out.println();
			}
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0){
				break;
			}else{
				for(int i = 1; i <= H; i++){
					String str = "";
					for(int j = 1; j <= W; j++){
						if((i == 1 || i == H) || (j == 1 || j == W)){
							str += "#";
						}else{
							str += ".";
						}
					}
					System.out.println(str);
				}
				System.out.println();
			}
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0){
				break;
			}else{
				for(int i = 1; i <= H; i++){
					String str = "";
					for(int j = 1; j <= W; j++){
						if((i == 1 || i == H) || (j == 1 || j == W)){
							str += "#";
						}else{
							str += ".";
						}
					}
					System.out.println(str);
				}
				System.out.println();
			}
		}
	}
}