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

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int i = 0;
		int j = 0;

		while(true){

			String[] input = br.readLine().split(" ");

			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);

			if( H==0 && W==0) break;

			for( i=0 ; i<H ; i++ ){
				if( i==0 | i==H-1 ){
					for( j=0 ; j<W ; j++){
						System.out.print("#");
					}
				}else{
					for( j=0 ; j<W ; j++ ){
						if( j==0|| j==W-1){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int i = 0;
		int j = 0;

		while(true){

			String[] input = br.readLine().split(" ");

			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);

			if( H==0 && W==0) break;

			for( i=0 ; i<H ; i++ ){
				if( i==0 | i==H-1 ){
					for( j=0 ; j<W ; j++){
						System.out.print("#");
					}
				}else{
					for( j=0 ; j<W ; j++ ){
						if( j==0|| j==W-1){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
} Main public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int i = 0;
		int j = 0;

		while(true){

			String[] input = br.readLine().split(" ");

			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);

			if( H==0 && W==0) break;

			for( i=0 ; i<H ; i++ ){
				if( i==0 | i==H-1 ){
					for( j=0 ; j<W ; j++){
						System.out.print("#");
					}
				}else{
					for( j=0 ; j<W ; j++ ){
						if( j==0|| j==W-1){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int i = 0;
		int j = 0;

		while(true){

			String[] input = br.readLine().split(" ");

			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);

			if( H==0 && W==0) break;

			for( i=0 ; i<H ; i++ ){
				if( i==0 | i==H-1 ){
					for( j=0 ; j<W ; j++){
						System.out.print("#");
					}
				}else{
					for( j=0 ; j<W ; j++ ){
						if( j==0|| j==W-1){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int i = 0; i 0 int j = 0; j 0 while(true){

			String[] input = br.readLine().split(" ");

			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);

			if( H==0 && W==0) break;

			for( i=0 ; i<H ; i++ ){
				if( i==0 | i==H-1 ){
					for( j=0 ; j<W ; j++){
						System.out.print("#");
					}
				}else{
					for( j=0 ; j<W ; j++ ){
						if( j==0|| j==W-1){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		} true {

			String[] input = br.readLine().split(" ");

			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);

			if( H==0 && W==0) break;

			for( i=0 ; i<H ; i++ ){
				if( i==0 | i==H-1 ){
					for( j=0 ; j<W ; j++){
						System.out.print("#");
					}
				}else{
					for( j=0 ; j<W ; j++ ){
						if( j==0|| j==W-1){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		} String[] input = br.readLine().split(" "); input br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int H = Integer.parseInt(input[0]); H Integer.parseInt(input[0]) Integer.parseInt Integer input[0] input 0 int W = Integer.parseInt(input[1]); W Integer.parseInt(input[1]) Integer.parseInt Integer input[1] input 1 if( H==0 && W==0) break; H==0 && W==0 H==0 H 0 W==0 W 0 break; for( i=0 ; i<H ; i++ ){
				if( i==0 | i==H-1 ){
					for( j=0 ; j<W ; j++){
						System.out.print("#");
					}
				}else{
					for( j=0 ; j<W ; j++ ){
						if( j==0|| j==W-1){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.print("\n");
			} i=0 ; i=0 i 0 i<H i H i++ i++ i {
				if( i==0 | i==H-1 ){
					for( j=0 ; j<W ; j++){
						System.out.print("#");
					}
				}else{
					for( j=0 ; j<W ; j++ ){
						if( j==0|| j==W-1){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.print("\n");
			} {
				if( i==0 | i==H-1 ){
					for( j=0 ; j<W ; j++){
						System.out.print("#");
					}
				}else{
					for( j=0 ; j<W ; j++ ){
						if( j==0|| j==W-1){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.print("\n");
			} if( i==0 | i==H-1 ){
					for( j=0 ; j<W ; j++){
						System.out.print("#");
					}
				}else{
					for( j=0 ; j<W ; j++ ){
						if( j==0|| j==W-1){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				} i==0 | i==H-1 i==0 i 0 i==H-1 i H-1 H 1 {
					for( j=0 ; j<W ; j++){
						System.out.print("#");
					}
				} for( j=0 ; j<W ; j++){
						System.out.print("#");
					} j=0 ; j=0 j 0 j<W j W j++ j++ j {
						System.out.print("#");
					} {
						System.out.print("#");
					} System.out.print("#") System.out.print System.out System System.out "#" {
					for( j=0 ; j<W ; j++ ){
						if( j==0|| j==W-1){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				} for( j=0 ; j<W ; j++ ){
						if( j==0|| j==W-1){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					} j=0 ; j=0 j 0 j<W j W j++ j++ j {
						if( j==0|| j==W-1){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					} {
						if( j==0|| j==W-1){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					} if( j==0|| j==W-1){
							System.out.print("#");
						}else{
							System.out.print(".");
						} j==0|| j==W-1 j==0 j 0 j==W-1 j W-1 W 1 {
							System.out.print("#");
						} System.out.print("#") System.out.print System.out System System.out "#" {
							System.out.print(".");
						} 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[] age age public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int i = 0;
		int j = 0;

		while(true){

			String[] input = br.readLine().split(" ");

			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);

			if( H==0 && W==0) break;

			for( i=0 ; i<H ; i++ ){
				if( i==0 | i==H-1 ){
					for( j=0 ; j<W ; j++){
						System.out.print("#");
					}
				}else{
					for( j=0 ; j<W ; j++ ){
						if( j==0|| j==W-1){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
} public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int i = 0;
		int j = 0;

		while(true){

			String[] input = br.readLine().split(" ");

			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);

			if( H==0 && W==0) break;

			for( i=0 ; i<H ; i++ ){
				if( i==0 | i==H-1 ){
					for( j=0 ; j<W ; j++){
						System.out.print("#");
					}
				}else{
					for( j=0 ; j<W ; j++ ){
						if( j==0|| j==W-1){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int i = 0;
		int j = 0;

		while(true){

			String[] input = br.readLine().split(" ");

			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);

			if( H==0 && W==0) break;

			for( i=0 ; i<H ; i++ ){
				if( i==0 | i==H-1 ){
					for( j=0 ; j<W ; j++){
						System.out.print("#");
					}
				}else{
					for( j=0 ; j<W ; j++ ){
						if( j==0|| j==W-1){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
}