import java.util.Scanner;
import java.util.Arrays;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		
		while(true){
			int h = scanner.nextInt();
			int w = scanner.nextInt();
			
			if(h == 0 && w == 0){
				break;
			}

			for(int i = 0; i < h; i++){
				if(i == 0 || i == h-1){
					for(int j = 0; j < w; j++){
					sb.append("#");
					}
					sb.append("\n");
				}else{
					sb.append("#");
					for(int j = 0; j < w-2; j++){
					sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
			}
			sb.append("\n");
		}
		System.out.print(sb);
	}
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		
		while(true){
			int h = scanner.nextInt();
			int w = scanner.nextInt();
			
			if(h == 0 && w == 0){
				break;
			}

			for(int i = 0; i < h; i++){
				if(i == 0 || i == h-1){
					for(int j = 0; j < w; j++){
					sb.append("#");
					}
					sb.append("\n");
				}else{
					sb.append("#");
					for(int j = 0; j < w-2; j++){
					sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
			}
			sb.append("\n");
		}
		System.out.print(sb);
	}
} Main public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		
		while(true){
			int h = scanner.nextInt();
			int w = scanner.nextInt();
			
			if(h == 0 && w == 0){
				break;
			}

			for(int i = 0; i < h; i++){
				if(i == 0 || i == h-1){
					for(int j = 0; j < w; j++){
					sb.append("#");
					}
					sb.append("\n");
				}else{
					sb.append("#");
					for(int j = 0; j < w-2; j++){
					sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
			}
			sb.append("\n");
		}
		System.out.print(sb);
	} main {
		Scanner scanner = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		
		while(true){
			int h = scanner.nextInt();
			int w = scanner.nextInt();
			
			if(h == 0 && w == 0){
				break;
			}

			for(int i = 0; i < h; i++){
				if(i == 0 || i == h-1){
					for(int j = 0; j < w; j++){
					sb.append("#");
					}
					sb.append("\n");
				}else{
					sb.append("#");
					for(int j = 0; j < w-2; j++){
					sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
			}
			sb.append("\n");
		}
		System.out.print(sb);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) StringBuilder sb = new StringBuilder(); sb new StringBuilder() while(true){
			int h = scanner.nextInt();
			int w = scanner.nextInt();
			
			if(h == 0 && w == 0){
				break;
			}

			for(int i = 0; i < h; i++){
				if(i == 0 || i == h-1){
					for(int j = 0; j < w; j++){
					sb.append("#");
					}
					sb.append("\n");
				}else{
					sb.append("#");
					for(int j = 0; j < w-2; j++){
					sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
			}
			sb.append("\n");
		} true {
			int h = scanner.nextInt();
			int w = scanner.nextInt();
			
			if(h == 0 && w == 0){
				break;
			}

			for(int i = 0; i < h; i++){
				if(i == 0 || i == h-1){
					for(int j = 0; j < w; j++){
					sb.append("#");
					}
					sb.append("\n");
				}else{
					sb.append("#");
					for(int j = 0; j < w-2; j++){
					sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
			}
			sb.append("\n");
		} 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; for(int i = 0; i < h; i++){
				if(i == 0 || i == h-1){
					for(int j = 0; j < w; j++){
					sb.append("#");
					}
					sb.append("\n");
				}else{
					sb.append("#");
					for(int j = 0; j < w-2; j++){
					sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
			} int i = 0; int i = 0; i 0 i < h i h i++ i++ i {
				if(i == 0 || i == h-1){
					for(int j = 0; j < w; j++){
					sb.append("#");
					}
					sb.append("\n");
				}else{
					sb.append("#");
					for(int j = 0; j < w-2; j++){
					sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
			} {
				if(i == 0 || i == h-1){
					for(int j = 0; j < w; j++){
					sb.append("#");
					}
					sb.append("\n");
				}else{
					sb.append("#");
					for(int j = 0; j < w-2; j++){
					sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
			} if(i == 0 || i == h-1){
					for(int j = 0; j < w; j++){
					sb.append("#");
					}
					sb.append("\n");
				}else{
					sb.append("#");
					for(int j = 0; j < w-2; j++){
					sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				} i == 0 || i == h-1 i == 0 i 0 i == h-1 i h-1 h 1 {
					for(int j = 0; j < w; j++){
					sb.append("#");
					}
					sb.append("\n");
				} for(int j = 0; j < w; j++){
					sb.append("#");
					} int j = 0; int j = 0; j 0 j < w j w j++ j++ j {
					sb.append("#");
					} {
					sb.append("#");
					} sb.append("#") sb.append sb "#" sb.append("\n") sb.append sb "\n" {
					sb.append("#");
					for(int j = 0; j < w-2; j++){
					sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				} sb.append("#") sb.append sb "#" for(int j = 0; j < w-2; j++){
					sb.append(".");
					} int j = 0; int j = 0; j 0 j < w-2 j w-2 w 2 j++ j++ j {
					sb.append(".");
					} {
					sb.append(".");
					} sb.append(".") sb.append sb "." sb.append("#") sb.append sb "#" sb.append("\n") sb.append sb "\n" sb.append("\n") sb.append sb "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args
import java.util.Scanner;
import java.util.Arrays;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		
		while(true){
			int h = scanner.nextInt();
			int w = scanner.nextInt();
			
			if(h == 0 && w == 0){
				break;
			}

			for(int i = 0; i < h; i++){
				if(i == 0 || i == h-1){
					for(int j = 0; j < w; j++){
					sb.append("#");
					}
					sb.append("\n");
				}else{
					sb.append("#");
					for(int j = 0; j < w-2; j++){
					sb.append(".");
					}
					sb.append("#");
					sb.append("\n");
				}
			}
			sb.append("\n");
		}
		System.out.print(sb);
	}
}