import java.util.Scanner;
class Main {
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		while(true){ 
		int H = scanner.nextInt();
		int W = scanner.nextInt();
		
		if ( H == 0 && W == 0 ){
			break;
			}
			else{
				int smallh;
				int smallw;
				
				for( smallh = 0; smallh < H; smallh++  ) {
					
					for( smallw = 0; smallw < W; smallw++ ) {
						if(smallw == 0 || smallw == W-1 || smallh == 0 || smallh == H-1){
						System.out.print("#");
						}else{
						System.out.print(".");
						}					
				 }
				 System.out.println();
			}	
		}
		System.out.println();
		}
	}
} import java.util.Scanner; Scanner java.util class Main {
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		while(true){ 
		int H = scanner.nextInt();
		int W = scanner.nextInt();
		
		if ( H == 0 && W == 0 ){
			break;
			}
			else{
				int smallh;
				int smallw;
				
				for( smallh = 0; smallh < H; smallh++  ) {
					
					for( smallw = 0; smallw < W; smallw++ ) {
						if(smallw == 0 || smallw == W-1 || smallh == 0 || smallh == H-1){
						System.out.print("#");
						}else{
						System.out.print(".");
						}					
				 }
				 System.out.println();
			}	
		}
		System.out.println();
		}
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		while(true){ 
		int H = scanner.nextInt();
		int W = scanner.nextInt();
		
		if ( H == 0 && W == 0 ){
			break;
			}
			else{
				int smallh;
				int smallw;
				
				for( smallh = 0; smallh < H; smallh++  ) {
					
					for( smallw = 0; smallw < W; smallw++ ) {
						if(smallw == 0 || smallw == W-1 || smallh == 0 || smallh == H-1){
						System.out.print("#");
						}else{
						System.out.print(".");
						}					
				 }
				 System.out.println();
			}	
		}
		System.out.println();
		}
	} main {
		Scanner scanner = new Scanner(System.in);
		
		while(true){ 
		int H = scanner.nextInt();
		int W = scanner.nextInt();
		
		if ( H == 0 && W == 0 ){
			break;
			}
			else{
				int smallh;
				int smallw;
				
				for( smallh = 0; smallh < H; smallh++  ) {
					
					for( smallw = 0; smallw < W; smallw++ ) {
						if(smallw == 0 || smallw == W-1 || smallh == 0 || smallh == H-1){
						System.out.print("#");
						}else{
						System.out.print(".");
						}					
				 }
				 System.out.println();
			}	
		}
		System.out.println();
		}
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) while(true){ 
		int H = scanner.nextInt();
		int W = scanner.nextInt();
		
		if ( H == 0 && W == 0 ){
			break;
			}
			else{
				int smallh;
				int smallw;
				
				for( smallh = 0; smallh < H; smallh++  ) {
					
					for( smallw = 0; smallw < W; smallw++ ) {
						if(smallw == 0 || smallw == W-1 || smallh == 0 || smallh == H-1){
						System.out.print("#");
						}else{
						System.out.print(".");
						}					
				 }
				 System.out.println();
			}	
		}
		System.out.println();
		} true { 
		int H = scanner.nextInt();
		int W = scanner.nextInt();
		
		if ( H == 0 && W == 0 ){
			break;
			}
			else{
				int smallh;
				int smallw;
				
				for( smallh = 0; smallh < H; smallh++  ) {
					
					for( smallw = 0; smallw < W; smallw++ ) {
						if(smallw == 0 || smallw == W-1 || smallh == 0 || smallh == H-1){
						System.out.print("#");
						}else{
						System.out.print(".");
						}					
				 }
				 System.out.println();
			}	
		}
		System.out.println();
		} int H = scanner.nextInt(); H scanner.nextInt() scanner.nextInt scanner int W = scanner.nextInt(); W scanner.nextInt() scanner.nextInt scanner if ( H == 0 && W == 0 ){
			break;
			}
			else{
				int smallh;
				int smallw;
				
				for( smallh = 0; smallh < H; smallh++  ) {
					
					for( smallw = 0; smallw < W; smallw++ ) {
						if(smallw == 0 || smallw == W-1 || smallh == 0 || smallh == H-1){
						System.out.print("#");
						}else{
						System.out.print(".");
						}					
				 }
				 System.out.println();
			}	
		} H == 0 && W == 0 H == 0 H 0 W == 0 W 0 {
			break;
			} break; {
				int smallh;
				int smallw;
				
				for( smallh = 0; smallh < H; smallh++  ) {
					
					for( smallw = 0; smallw < W; smallw++ ) {
						if(smallw == 0 || smallw == W-1 || smallh == 0 || smallh == H-1){
						System.out.print("#");
						}else{
						System.out.print(".");
						}					
				 }
				 System.out.println();
			}	
		} int smallh; smallh int smallw; smallw for( smallh = 0; smallh < H; smallh++  ) {
					
					for( smallw = 0; smallw < W; smallw++ ) {
						if(smallw == 0 || smallw == W-1 || smallh == 0 || smallh == H-1){
						System.out.print("#");
						}else{
						System.out.print(".");
						}					
				 }
				 System.out.println();
			} smallh = 0; smallh = 0 smallh 0 smallh < H smallh H smallh++ smallh++ smallh {
					
					for( smallw = 0; smallw < W; smallw++ ) {
						if(smallw == 0 || smallw == W-1 || smallh == 0 || smallh == H-1){
						System.out.print("#");
						}else{
						System.out.print(".");
						}					
				 }
				 System.out.println();
			} {
					
					for( smallw = 0; smallw < W; smallw++ ) {
						if(smallw == 0 || smallw == W-1 || smallh == 0 || smallh == H-1){
						System.out.print("#");
						}else{
						System.out.print(".");
						}					
				 }
				 System.out.println();
			} for( smallw = 0; smallw < W; smallw++ ) {
						if(smallw == 0 || smallw == W-1 || smallh == 0 || smallh == H-1){
						System.out.print("#");
						}else{
						System.out.print(".");
						}					
				 } smallw = 0; smallw = 0 smallw 0 smallw < W smallw W smallw++ smallw++ smallw {
						if(smallw == 0 || smallw == W-1 || smallh == 0 || smallh == H-1){
						System.out.print("#");
						}else{
						System.out.print(".");
						}					
				 } {
						if(smallw == 0 || smallw == W-1 || smallh == 0 || smallh == H-1){
						System.out.print("#");
						}else{
						System.out.print(".");
						}					
				 } if(smallw == 0 || smallw == W-1 || smallh == 0 || smallh == H-1){
						System.out.print("#");
						}else{
						System.out.print(".");
						} smallw == 0 || smallw == W-1 || smallh == 0 || smallh == H-1 smallh == 0 smallw == 0 || smallw == W-1 || smallh == 0 || smallh == H-1 smallw == 0 smallw 0 smallw == W-1 smallw W-1 W 1 smallh == 0 smallh 0 smallh == H-1 smallh H-1 H 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.println() System.out.println System.out System System.out System.out.println() System.out.println System.out System System.out String[] args args
import java.util.Scanner;
class Main {
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		while(true){ 
		int H = scanner.nextInt();
		int W = scanner.nextInt();
		
		if ( H == 0 && W == 0 ){
			break;
			}
			else{
				int smallh;
				int smallw;
				
				for( smallh = 0; smallh < H; smallh++  ) {
					
					for( smallw = 0; smallw < W; smallw++ ) {
						if(smallw == 0 || smallw == W-1 || smallh == 0 || smallh == H-1){
						System.out.print("#");
						}else{
						System.out.print(".");
						}					
				 }
				 System.out.println();
			}	
		}
		System.out.println();
		}
	}
}