import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
	
		try{
	BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));

	while(true){
    String input = buf.readLine();
	String[] strAry = input.split(" ");
    int H = Integer.parseInt(strAry[0]);
    int W = Integer.parseInt(strAry[1]);
	
	if(H == 0  && W == 0){
		break;
	}
	
	for (int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++){
			if((i == 0 || i == H-1) || (j ==0 || j == W-1)){
			System.out.printf("#");
				}else{
			System.out.printf(".");
			}
		}
		System.out.printf("\n");
	}
	System.out.printf("\n");
	}
} catch (Exception e) {

	System.out.println("????????????");
	
}
		 }
    } import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) throws Exception {
	
		try{
	BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));

	while(true){
    String input = buf.readLine();
	String[] strAry = input.split(" ");
    int H = Integer.parseInt(strAry[0]);
    int W = Integer.parseInt(strAry[1]);
	
	if(H == 0  && W == 0){
		break;
	}
	
	for (int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++){
			if((i == 0 || i == H-1) || (j ==0 || j == W-1)){
			System.out.printf("#");
				}else{
			System.out.printf(".");
			}
		}
		System.out.printf("\n");
	}
	System.out.printf("\n");
	}
} catch (Exception e) {

	System.out.println("????????????");
	
}
		 }
    } Main public static void main(String[] args) throws Exception {
	
		try{
	BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));

	while(true){
    String input = buf.readLine();
	String[] strAry = input.split(" ");
    int H = Integer.parseInt(strAry[0]);
    int W = Integer.parseInt(strAry[1]);
	
	if(H == 0  && W == 0){
		break;
	}
	
	for (int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++){
			if((i == 0 || i == H-1) || (j ==0 || j == W-1)){
			System.out.printf("#");
				}else{
			System.out.printf(".");
			}
		}
		System.out.printf("\n");
	}
	System.out.printf("\n");
	}
} catch (Exception e) {

	System.out.println("????????????");
	
}
		 } main {
	
		try{
	BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));

	while(true){
    String input = buf.readLine();
	String[] strAry = input.split(" ");
    int H = Integer.parseInt(strAry[0]);
    int W = Integer.parseInt(strAry[1]);
	
	if(H == 0  && W == 0){
		break;
	}
	
	for (int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++){
			if((i == 0 || i == H-1) || (j ==0 || j == W-1)){
			System.out.printf("#");
				}else{
			System.out.printf(".");
			}
		}
		System.out.printf("\n");
	}
	System.out.printf("\n");
	}
} catch (Exception e) {

	System.out.println("????????????");
	
}
		 } try{
	BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));

	while(true){
    String input = buf.readLine();
	String[] strAry = input.split(" ");
    int H = Integer.parseInt(strAry[0]);
    int W = Integer.parseInt(strAry[1]);
	
	if(H == 0  && W == 0){
		break;
	}
	
	for (int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++){
			if((i == 0 || i == H-1) || (j ==0 || j == W-1)){
			System.out.printf("#");
				}else{
			System.out.printf(".");
			}
		}
		System.out.printf("\n");
	}
	System.out.printf("\n");
	}
} catch (Exception e) {

	System.out.println("????????????");
	
} catch (Exception e) {

	System.out.println("????????????");
	
} Exception e {

	System.out.println("????????????");
	
} System.out.println("????????????") System.out.println System.out System System.out "????????????" {
	BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));

	while(true){
    String input = buf.readLine();
	String[] strAry = input.split(" ");
    int H = Integer.parseInt(strAry[0]);
    int W = Integer.parseInt(strAry[1]);
	
	if(H == 0  && W == 0){
		break;
	}
	
	for (int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++){
			if((i == 0 || i == H-1) || (j ==0 || j == W-1)){
			System.out.printf("#");
				}else{
			System.out.printf(".");
			}
		}
		System.out.printf("\n");
	}
	System.out.printf("\n");
	}
} BufferedReader buf = new BufferedReader(new InputStreamReader(System.in)); buf new BufferedReader(new InputStreamReader(System.in)) while(true){
    String input = buf.readLine();
	String[] strAry = input.split(" ");
    int H = Integer.parseInt(strAry[0]);
    int W = Integer.parseInt(strAry[1]);
	
	if(H == 0  && W == 0){
		break;
	}
	
	for (int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++){
			if((i == 0 || i == H-1) || (j ==0 || j == W-1)){
			System.out.printf("#");
				}else{
			System.out.printf(".");
			}
		}
		System.out.printf("\n");
	}
	System.out.printf("\n");
	} true {
    String input = buf.readLine();
	String[] strAry = input.split(" ");
    int H = Integer.parseInt(strAry[0]);
    int W = Integer.parseInt(strAry[1]);
	
	if(H == 0  && W == 0){
		break;
	}
	
	for (int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++){
			if((i == 0 || i == H-1) || (j ==0 || j == W-1)){
			System.out.printf("#");
				}else{
			System.out.printf(".");
			}
		}
		System.out.printf("\n");
	}
	System.out.printf("\n");
	} String input = buf.readLine(); input buf.readLine() buf.readLine buf String[] strAry = input.split(" "); strAry input.split(" ") input.split input " " int H = Integer.parseInt(strAry[0]); H Integer.parseInt(strAry[0]) Integer.parseInt Integer strAry[0] strAry 0 int W = Integer.parseInt(strAry[1]); W Integer.parseInt(strAry[1]) Integer.parseInt Integer strAry[1] strAry 1 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++) {
		for(int j = 0; j < W; j++){
			if((i == 0 || i == H-1) || (j ==0 || j == W-1)){
			System.out.printf("#");
				}else{
			System.out.printf(".");
			}
		}
		System.out.printf("\n");
	} int i = 0; int i = 0; i 0 i < H i H i++ i++ i {
		for(int j = 0; j < W; j++){
			if((i == 0 || i == H-1) || (j ==0 || j == W-1)){
			System.out.printf("#");
				}else{
			System.out.printf(".");
			}
		}
		System.out.printf("\n");
	} {
		for(int j = 0; j < W; j++){
			if((i == 0 || i == H-1) || (j ==0 || j == W-1)){
			System.out.printf("#");
				}else{
			System.out.printf(".");
			}
		}
		System.out.printf("\n");
	} for(int j = 0; j < W; j++){
			if((i == 0 || i == H-1) || (j ==0 || j == W-1)){
			System.out.printf("#");
				}else{
			System.out.printf(".");
			}
		} int j = 0; int j = 0; j 0 j < W j W j++ j++ j {
			if((i == 0 || i == H-1) || (j ==0 || j == W-1)){
			System.out.printf("#");
				}else{
			System.out.printf(".");
			}
		} {
			if((i == 0 || i == H-1) || (j ==0 || j == W-1)){
			System.out.printf("#");
				}else{
			System.out.printf(".");
			}
		} if((i == 0 || i == H-1) || (j ==0 || j == W-1)){
			System.out.printf("#");
				}else{
			System.out.printf(".");
			} (i == 0 || i == H-1) || (j ==0 || j == W-1) (i == 0 || i == H-1) i == 0 i 0 i == H-1 i H-1 H 1 (j ==0 || j == W-1) j ==0 j 0 j == W-1 j W-1 W 1 {
			System.out.printf("#");
				} System.out.printf("#") System.out.printf System.out System System.out "#" {
			System.out.printf(".");
			} System.out.printf(".") System.out.printf System.out System System.out "." System.out.printf("\n") System.out.printf System.out System System.out "\n" System.out.printf("\n") System.out.printf System.out System System.out "\n" String[] args args public class Main {
	public static void main(String[] args) throws Exception {
	
		try{
	BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));

	while(true){
    String input = buf.readLine();
	String[] strAry = input.split(" ");
    int H = Integer.parseInt(strAry[0]);
    int W = Integer.parseInt(strAry[1]);
	
	if(H == 0  && W == 0){
		break;
	}
	
	for (int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++){
			if((i == 0 || i == H-1) || (j ==0 || j == W-1)){
			System.out.printf("#");
				}else{
			System.out.printf(".");
			}
		}
		System.out.printf("\n");
	}
	System.out.printf("\n");
	}
} catch (Exception e) {

	System.out.println("????????????");
	
}
		 }
    } public class Main {
	public static void main(String[] args) throws Exception {
	
		try{
	BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));

	while(true){
    String input = buf.readLine();
	String[] strAry = input.split(" ");
    int H = Integer.parseInt(strAry[0]);
    int W = Integer.parseInt(strAry[1]);
	
	if(H == 0  && W == 0){
		break;
	}
	
	for (int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++){
			if((i == 0 || i == H-1) || (j ==0 || j == W-1)){
			System.out.printf("#");
				}else{
			System.out.printf(".");
			}
		}
		System.out.printf("\n");
	}
	System.out.printf("\n");
	}
} catch (Exception e) {

	System.out.println("????????????");
	
}
		 }
    } Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
	
		try{
	BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));

	while(true){
    String input = buf.readLine();
	String[] strAry = input.split(" ");
    int H = Integer.parseInt(strAry[0]);
    int W = Integer.parseInt(strAry[1]);
	
	if(H == 0  && W == 0){
		break;
	}
	
	for (int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++){
			if((i == 0 || i == H-1) || (j ==0 || j == W-1)){
			System.out.printf("#");
				}else{
			System.out.printf(".");
			}
		}
		System.out.printf("\n");
	}
	System.out.printf("\n");
	}
} catch (Exception e) {

	System.out.println("????????????");
	
}
		 }
    }