import java.util.*;

public class Main{

	public static void main(String[] args) {
		scan();
	}
	public static void scan() {
		Scanner scanner = new Scanner(System.in);
		while(true){
			int H = scanner.nextInt();
			int W = scanner.nextInt();
			if(H == 0 && W == 0){break;}
			Print(H , W);
			System.out.println("");
			
		}
		scanner.close();
		return ;
	}
	public static void Print(int H, int W){
		for(int y = 0 ; y < H ; y++){
			for(int x = 0; x < W ; x++){
				if(y==0 || x == 0 || y == H-1 || x == W-1){
					System.out.print("#");
				}
				else {
					System.out.print(".");
				}
			}
			System.out.println("");
		}
		return;
	}	
	
	
} import java.util.*; util.* java public class Main{

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

	public static void main(String[] args) {
		scan();
	}
	public static void scan() {
		Scanner scanner = new Scanner(System.in);
		while(true){
			int H = scanner.nextInt();
			int W = scanner.nextInt();
			if(H == 0 && W == 0){break;}
			Print(H , W);
			System.out.println("");
			
		}
		scanner.close();
		return ;
	}
	public static void Print(int H, int W){
		for(int y = 0 ; y < H ; y++){
			for(int x = 0; x < W ; x++){
				if(y==0 || x == 0 || y == H-1 || x == W-1){
					System.out.print("#");
				}
				else {
					System.out.print(".");
				}
			}
			System.out.println("");
		}
		return;
	}	
	
	
} public class Main{

	public static void main(String[] args) {
		scan();
	}
	public static void scan() {
		Scanner scanner = new Scanner(System.in);
		while(true){
			int H = scanner.nextInt();
			int W = scanner.nextInt();
			if(H == 0 && W == 0){break;}
			Print(H , W);
			System.out.println("");
			
		}
		scanner.close();
		return ;
	}
	public static void Print(int H, int W){
		for(int y = 0 ; y < H ; y++){
			for(int x = 0; x < W ; x++){
				if(y==0 || x == 0 || y == H-1 || x == W-1){
					System.out.print("#");
				}
				else {
					System.out.print(".");
				}
			}
			System.out.println("");
		}
		return;
	}	
	
	
} Main
import java.util.*;

public class Main{

	public static void main(String[] args) {
		scan();
	}
	public static void scan() {
		Scanner scanner = new Scanner(System.in);
		while(true){
			int H = scanner.nextInt();
			int W = scanner.nextInt();
			if(H == 0 && W == 0){break;}
			Print(H , W);
			System.out.println("");
			
		}
		scanner.close();
		return ;
	}
	public static void Print(int H, int W){
		for(int y = 0 ; y < H ; y++){
			for(int x = 0; x < W ; x++){
				if(y==0 || x == 0 || y == H-1 || x == W-1){
					System.out.print("#");
				}
				else {
					System.out.print(".");
				}
			}
			System.out.println("");
		}
		return;
	}	
	
	
}