import java.util.Scanner;

public class Main {
	private void rect(){
		Scanner scanner = new Scanner(System.in);
		
		while(scanner.hasNextInt()){
			int h =scanner.nextInt();
			int w =scanner.nextInt();
			if(h==0 && w==0)break;
			
			if(3<=h && h<=300 && 3<=w && w<=300){
				for(int j=0; j<w; j++){ //top
					System.out.printf("#");
				}System.out.println("");
				
				for(int i=1; i<h-1; i++){
					System.out.printf("#"); //right
					for(int j=1; j<w-1; j++){
						System.out.printf(".");
					}System.out.println("#"); //left
				}
				
				for(int j=0; j<w; j++){ //bottom
					System.out.printf("#");
				}System.out.println("");
				System.out.println("");
			}
		}
	}
	
	public static void main(String[] args) {
		Main run =new Main();
		run.rect();

	}
} import java.util.Scanner; Scanner java.util public class Main {
	private void rect(){
		Scanner scanner = new Scanner(System.in);
		
		while(scanner.hasNextInt()){
			int h =scanner.nextInt();
			int w =scanner.nextInt();
			if(h==0 && w==0)break;
			
			if(3<=h && h<=300 && 3<=w && w<=300){
				for(int j=0; j<w; j++){ //top
					System.out.printf("#");
				}System.out.println("");
				
				for(int i=1; i<h-1; i++){
					System.out.printf("#"); //right
					for(int j=1; j<w-1; j++){
						System.out.printf(".");
					}System.out.println("#"); //left
				}
				
				for(int j=0; j<w; j++){ //bottom
					System.out.printf("#");
				}System.out.println("");
				System.out.println("");
			}
		}
	}
	
	public static void main(String[] args) {
		Main run =new Main();
		run.rect();

	}
} Main private void rect(){
		Scanner scanner = new Scanner(System.in);
		
		while(scanner.hasNextInt()){
			int h =scanner.nextInt();
			int w =scanner.nextInt();
			if(h==0 && w==0)break;
			
			if(3<=h && h<=300 && 3<=w && w<=300){
				for(int j=0; j<w; j++){ //top
					System.out.printf("#");
				}System.out.println("");
				
				for(int i=1; i<h-1; i++){
					System.out.printf("#"); //right
					for(int j=1; j<w-1; j++){
						System.out.printf(".");
					}System.out.println("#"); //left
				}
				
				for(int j=0; j<w; j++){ //bottom
					System.out.printf("#");
				}System.out.println("");
				System.out.println("");
			}
		}
	} rect {
		Scanner scanner = new Scanner(System.in);
		
		while(scanner.hasNextInt()){
			int h =scanner.nextInt();
			int w =scanner.nextInt();
			if(h==0 && w==0)break;
			
			if(3<=h && h<=300 && 3<=w && w<=300){
				for(int j=0; j<w; j++){ //top
					System.out.printf("#");
				}System.out.println("");
				
				for(int i=1; i<h-1; i++){
					System.out.printf("#"); //right
					for(int j=1; j<w-1; j++){
						System.out.printf(".");
					}System.out.println("#"); //left
				}
				
				for(int j=0; j<w; j++){ //bottom
					System.out.printf("#");
				}System.out.println("");
				System.out.println("");
			}
		}
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) while(scanner.hasNextInt()){
			int h =scanner.nextInt();
			int w =scanner.nextInt();
			if(h==0 && w==0)break;
			
			if(3<=h && h<=300 && 3<=w && w<=300){
				for(int j=0; j<w; j++){ //top
					System.out.printf("#");
				}System.out.println("");
				
				for(int i=1; i<h-1; i++){
					System.out.printf("#"); //right
					for(int j=1; j<w-1; j++){
						System.out.printf(".");
					}System.out.println("#"); //left
				}
				
				for(int j=0; j<w; j++){ //bottom
					System.out.printf("#");
				}System.out.println("");
				System.out.println("");
			}
		} scanner.hasNextInt() scanner.hasNextInt scanner {
			int h =scanner.nextInt();
			int w =scanner.nextInt();
			if(h==0 && w==0)break;
			
			if(3<=h && h<=300 && 3<=w && w<=300){
				for(int j=0; j<w; j++){ //top
					System.out.printf("#");
				}System.out.println("");
				
				for(int i=1; i<h-1; i++){
					System.out.printf("#"); //right
					for(int j=1; j<w-1; j++){
						System.out.printf(".");
					}System.out.println("#"); //left
				}
				
				for(int j=0; j<w; j++){ //bottom
					System.out.printf("#");
				}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; h==0 && w==0 h==0 h 0 w==0 w 0 break; if(3<=h && h<=300 && 3<=w && w<=300){
				for(int j=0; j<w; j++){ //top
					System.out.printf("#");
				}System.out.println("");
				
				for(int i=1; i<h-1; i++){
					System.out.printf("#"); //right
					for(int j=1; j<w-1; j++){
						System.out.printf(".");
					}System.out.println("#"); //left
				}
				
				for(int j=0; j<w; j++){ //bottom
					System.out.printf("#");
				}System.out.println("");
				System.out.println("");
			} 3<=h && h<=300 && 3<=w && w<=300 3<=w 3<=h && h<=300 && 3<=w && w<=300 3<=h 3 h h<=300 h 300 3<=w 3 w w<=300 w 300 {
				for(int j=0; j<w; j++){ //top
					System.out.printf("#");
				}System.out.println("");
				
				for(int i=1; i<h-1; i++){
					System.out.printf("#"); //right
					for(int j=1; j<w-1; j++){
						System.out.printf(".");
					}System.out.println("#"); //left
				}
				
				for(int j=0; j<w; j++){ //bottom
					System.out.printf("#");
				}System.out.println("");
				System.out.println("");
			} for(int j=0; j<w; j++){ //top
					System.out.printf("#");
				} int j=0; int j=0; j 0 j<w j w j++ j++ j { //top
					System.out.printf("#");
				} { //top
					System.out.printf("#");
				} System.out.printf("#") System.out.printf System.out System System.out "#" System.out.println("") System.out.println System.out System System.out "" for(int i=1; i<h-1; i++){
					System.out.printf("#"); //right
					for(int j=1; j<w-1; j++){
						System.out.printf(".");
					}System.out.println("#"); //left
				} int i=1; int i=1; i 1 i<h-1 i h-1 h 1 i++ i++ i {
					System.out.printf("#"); //right
					for(int j=1; j<w-1; j++){
						System.out.printf(".");
					}System.out.println("#"); //left
				} {
					System.out.printf("#"); //right
					for(int j=1; j<w-1; j++){
						System.out.printf(".");
					}System.out.println("#"); //left
				} System.out.printf("#") System.out.printf System.out System System.out "#" for(int j=1; j<w-1; j++){
						System.out.printf(".");
					} int j=1; int j=1; j 1 j<w-1 j w-1 w 1 j++ j++ j {
						System.out.printf(".");
					} {
						System.out.printf(".");
					} System.out.printf(".") System.out.printf System.out System System.out "." System.out.println("#") System.out.println System.out System System.out "#" for(int j=0; j<w; j++){ //bottom
					System.out.printf("#");
				} int j=0; int j=0; j 0 j<w j w j++ j++ j { //bottom
					System.out.printf("#");
				} { //bottom
					System.out.printf("#");
				} System.out.printf("#") System.out.printf 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 "" public static void main(String[] args) {
		Main run =new Main();
		run.rect();

	} main {
		Main run =new Main();
		run.rect();

	} Main run =new Main(); run new Main() run.rect() run.rect run String[] args args public class Main {
	private void rect(){
		Scanner scanner = new Scanner(System.in);
		
		while(scanner.hasNextInt()){
			int h =scanner.nextInt();
			int w =scanner.nextInt();
			if(h==0 && w==0)break;
			
			if(3<=h && h<=300 && 3<=w && w<=300){
				for(int j=0; j<w; j++){ //top
					System.out.printf("#");
				}System.out.println("");
				
				for(int i=1; i<h-1; i++){
					System.out.printf("#"); //right
					for(int j=1; j<w-1; j++){
						System.out.printf(".");
					}System.out.println("#"); //left
				}
				
				for(int j=0; j<w; j++){ //bottom
					System.out.printf("#");
				}System.out.println("");
				System.out.println("");
			}
		}
	}
	
	public static void main(String[] args) {
		Main run =new Main();
		run.rect();

	}
} public class Main {
	private void rect(){
		Scanner scanner = new Scanner(System.in);
		
		while(scanner.hasNextInt()){
			int h =scanner.nextInt();
			int w =scanner.nextInt();
			if(h==0 && w==0)break;
			
			if(3<=h && h<=300 && 3<=w && w<=300){
				for(int j=0; j<w; j++){ //top
					System.out.printf("#");
				}System.out.println("");
				
				for(int i=1; i<h-1; i++){
					System.out.printf("#"); //right
					for(int j=1; j<w-1; j++){
						System.out.printf(".");
					}System.out.println("#"); //left
				}
				
				for(int j=0; j<w; j++){ //bottom
					System.out.printf("#");
				}System.out.println("");
				System.out.println("");
			}
		}
	}
	
	public static void main(String[] args) {
		Main run =new Main();
		run.rect();

	}
} Main
import java.util.Scanner;

public class Main {
	private void rect(){
		Scanner scanner = new Scanner(System.in);
		
		while(scanner.hasNextInt()){
			int h =scanner.nextInt();
			int w =scanner.nextInt();
			if(h==0 && w==0)break;
			
			if(3<=h && h<=300 && 3<=w && w<=300){
				for(int j=0; j<w; j++){ //top
					System.out.printf("#");
				}System.out.println("");
				
				for(int i=1; i<h-1; i++){
					System.out.printf("#"); //right
					for(int j=1; j<w-1; j++){
						System.out.printf(".");
					}System.out.println("#"); //left
				}
				
				for(int j=0; j<w; j++){ //bottom
					System.out.printf("#");
				}System.out.println("");
				System.out.println("");
			}
		}
	}
	
	public static void main(String[] args) {
		Main run =new Main();
		run.rect();

	}
}