import java.util.Scanner;

class Main {

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		int str1 = scan.nextInt();
		int str2 = scan.nextInt();
		
		int i = 0;
		
		while(str1 != 0 && str2 != 0){
			for(i = 0; i < str1; i++){
				System.out.print("#");
				for(int j = 1; j < str2 - 1; j++){
					if(i == 0 || i == str1 - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
				}
				}
				System.out.print("#");
				System.out.println();
			}
			System.out.println();
			str1 = scan.nextInt();
			str2 = scan.nextInt();

		}
		
	}
} import java.util.Scanner; Scanner java.util class Main {

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		int str1 = scan.nextInt();
		int str2 = scan.nextInt();
		
		int i = 0;
		
		while(str1 != 0 && str2 != 0){
			for(i = 0; i < str1; i++){
				System.out.print("#");
				for(int j = 1; j < str2 - 1; j++){
					if(i == 0 || i == str1 - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
				}
				}
				System.out.print("#");
				System.out.println();
			}
			System.out.println();
			str1 = scan.nextInt();
			str2 = scan.nextInt();

		}
		
	}
} Main public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		int str1 = scan.nextInt();
		int str2 = scan.nextInt();
		
		int i = 0;
		
		while(str1 != 0 && str2 != 0){
			for(i = 0; i < str1; i++){
				System.out.print("#");
				for(int j = 1; j < str2 - 1; j++){
					if(i == 0 || i == str1 - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
				}
				}
				System.out.print("#");
				System.out.println();
			}
			System.out.println();
			str1 = scan.nextInt();
			str2 = scan.nextInt();

		}
		
	} main {
		Scanner scan = new Scanner(System.in);

		int str1 = scan.nextInt();
		int str2 = scan.nextInt();
		
		int i = 0;
		
		while(str1 != 0 && str2 != 0){
			for(i = 0; i < str1; i++){
				System.out.print("#");
				for(int j = 1; j < str2 - 1; j++){
					if(i == 0 || i == str1 - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
				}
				}
				System.out.print("#");
				System.out.println();
			}
			System.out.println();
			str1 = scan.nextInt();
			str2 = scan.nextInt();

		}
		
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int str1 = scan.nextInt(); str1 scan.nextInt() scan.nextInt scan int str2 = scan.nextInt(); str2 scan.nextInt() scan.nextInt scan int i = 0; i 0 while(str1 != 0 && str2 != 0){
			for(i = 0; i < str1; i++){
				System.out.print("#");
				for(int j = 1; j < str2 - 1; j++){
					if(i == 0 || i == str1 - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
				}
				}
				System.out.print("#");
				System.out.println();
			}
			System.out.println();
			str1 = scan.nextInt();
			str2 = scan.nextInt();

		} str1 != 0 && str2 != 0 str1 != 0 str1 0 str2 != 0 str2 0 {
			for(i = 0; i < str1; i++){
				System.out.print("#");
				for(int j = 1; j < str2 - 1; j++){
					if(i == 0 || i == str1 - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
				}
				}
				System.out.print("#");
				System.out.println();
			}
			System.out.println();
			str1 = scan.nextInt();
			str2 = scan.nextInt();

		} for(i = 0; i < str1; i++){
				System.out.print("#");
				for(int j = 1; j < str2 - 1; j++){
					if(i == 0 || i == str1 - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
				}
				}
				System.out.print("#");
				System.out.println();
			} i = 0; i = 0 i 0 i < str1 i str1 i++ i++ i {
				System.out.print("#");
				for(int j = 1; j < str2 - 1; j++){
					if(i == 0 || i == str1 - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
				}
				}
				System.out.print("#");
				System.out.println();
			} {
				System.out.print("#");
				for(int j = 1; j < str2 - 1; j++){
					if(i == 0 || i == str1 - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
				}
				}
				System.out.print("#");
				System.out.println();
			} System.out.print("#") System.out.print System.out System System.out "#" for(int j = 1; j < str2 - 1; j++){
					if(i == 0 || i == str1 - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
				}
				} int j = 1; int j = 1; j 1 j < str2 - 1 j str2 - 1 str2 1 j++ j++ j {
					if(i == 0 || i == str1 - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
				}
				} {
					if(i == 0 || i == str1 - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
				}
				} if(i == 0 || i == str1 - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
				} i == 0 || i == str1 - 1 i == 0 i 0 i == str1 - 1 i str1 - 1 str1 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("#") 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 str1 = scan.nextInt() str1 scan.nextInt() scan.nextInt scan str2 = scan.nextInt() str2 scan.nextInt() scan.nextInt scan String[] args args
import java.util.Scanner;

class Main {

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		int str1 = scan.nextInt();
		int str2 = scan.nextInt();
		
		int i = 0;
		
		while(str1 != 0 && str2 != 0){
			for(i = 0; i < str1; i++){
				System.out.print("#");
				for(int j = 1; j < str2 - 1; j++){
					if(i == 0 || i == str1 - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
				}
				}
				System.out.print("#");
				System.out.println();
			}
			System.out.println();
			str1 = scan.nextInt();
			str2 = scan.nextInt();

		}
		
	}
}