import java.io.*;
  
class Main{
	public static void main(String[] args) throws IOException{

		int x,y,i,j;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String[] str = br.readLine().split(" ");
			x = Integer.parseInt(str[0]);
			y = Integer.parseInt(str[1]);

			if(x == 0 && y ==0){
				break;
			}

			for(i = 0; i < x; i++){
				for(j = 0; j < y; j++){
					if(i == 0 || i+1 == x){
						System.out.printf("#");
					}else if(j ==0 || j+1 == y){
						System.out.printf("#");
					}else {
						System.out.printf(".");
					}
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		}
  	}
} import java.io.*; io.* java class Main{
	public static void main(String[] args) throws IOException{

		int x,y,i,j;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String[] str = br.readLine().split(" ");
			x = Integer.parseInt(str[0]);
			y = Integer.parseInt(str[1]);

			if(x == 0 && y ==0){
				break;
			}

			for(i = 0; i < x; i++){
				for(j = 0; j < y; j++){
					if(i == 0 || i+1 == x){
						System.out.printf("#");
					}else if(j ==0 || j+1 == y){
						System.out.printf("#");
					}else {
						System.out.printf(".");
					}
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		}
  	}
} Main public static void main(String[] args) throws IOException{

		int x,y,i,j;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String[] str = br.readLine().split(" ");
			x = Integer.parseInt(str[0]);
			y = Integer.parseInt(str[1]);

			if(x == 0 && y ==0){
				break;
			}

			for(i = 0; i < x; i++){
				for(j = 0; j < y; j++){
					if(i == 0 || i+1 == x){
						System.out.printf("#");
					}else if(j ==0 || j+1 == y){
						System.out.printf("#");
					}else {
						System.out.printf(".");
					}
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		}
  	} main {

		int x,y,i,j;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String[] str = br.readLine().split(" ");
			x = Integer.parseInt(str[0]);
			y = Integer.parseInt(str[1]);

			if(x == 0 && y ==0){
				break;
			}

			for(i = 0; i < x; i++){
				for(j = 0; j < y; j++){
					if(i == 0 || i+1 == x){
						System.out.printf("#");
					}else if(j ==0 || j+1 == y){
						System.out.printf("#");
					}else {
						System.out.printf(".");
					}
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		}
  	} int x x y y i i j; j BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
			String[] str = br.readLine().split(" ");
			x = Integer.parseInt(str[0]);
			y = Integer.parseInt(str[1]);

			if(x == 0 && y ==0){
				break;
			}

			for(i = 0; i < x; i++){
				for(j = 0; j < y; j++){
					if(i == 0 || i+1 == x){
						System.out.printf("#");
					}else if(j ==0 || j+1 == y){
						System.out.printf("#");
					}else {
						System.out.printf(".");
					}
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		} true {
			String[] str = br.readLine().split(" ");
			x = Integer.parseInt(str[0]);
			y = Integer.parseInt(str[1]);

			if(x == 0 && y ==0){
				break;
			}

			for(i = 0; i < x; i++){
				for(j = 0; j < y; j++){
					if(i == 0 || i+1 == x){
						System.out.printf("#");
					}else if(j ==0 || j+1 == y){
						System.out.printf("#");
					}else {
						System.out.printf(".");
					}
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		} String[] str = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " x = Integer.parseInt(str[0]) x Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 y = Integer.parseInt(str[1]) y Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 if(x == 0 && y ==0){
				break;
			} x == 0 && y ==0 x == 0 x 0 y ==0 y 0 {
				break;
			} break; for(i = 0; i < x; i++){
				for(j = 0; j < y; j++){
					if(i == 0 || i+1 == x){
						System.out.printf("#");
					}else if(j ==0 || j+1 == y){
						System.out.printf("#");
					}else {
						System.out.printf(".");
					}
				}
				System.out.printf("\n");
			} i = 0; i = 0 i 0 i < x i x i++ i++ i {
				for(j = 0; j < y; j++){
					if(i == 0 || i+1 == x){
						System.out.printf("#");
					}else if(j ==0 || j+1 == y){
						System.out.printf("#");
					}else {
						System.out.printf(".");
					}
				}
				System.out.printf("\n");
			} {
				for(j = 0; j < y; j++){
					if(i == 0 || i+1 == x){
						System.out.printf("#");
					}else if(j ==0 || j+1 == y){
						System.out.printf("#");
					}else {
						System.out.printf(".");
					}
				}
				System.out.printf("\n");
			} for(j = 0; j < y; j++){
					if(i == 0 || i+1 == x){
						System.out.printf("#");
					}else if(j ==0 || j+1 == y){
						System.out.printf("#");
					}else {
						System.out.printf(".");
					}
				} j = 0; j = 0 j 0 j < y j y j++ j++ j {
					if(i == 0 || i+1 == x){
						System.out.printf("#");
					}else if(j ==0 || j+1 == y){
						System.out.printf("#");
					}else {
						System.out.printf(".");
					}
				} {
					if(i == 0 || i+1 == x){
						System.out.printf("#");
					}else if(j ==0 || j+1 == y){
						System.out.printf("#");
					}else {
						System.out.printf(".");
					}
				} if(i == 0 || i+1 == x){
						System.out.printf("#");
					}else if(j ==0 || j+1 == y){
						System.out.printf("#");
					}else {
						System.out.printf(".");
					} i == 0 || i+1 == x i == 0 i 0 i+1 == x i+1 i 1 x {
						System.out.printf("#");
					} System.out.printf("#") System.out.printf System.out System System.out "#" if(j ==0 || j+1 == y){
						System.out.printf("#");
					}else {
						System.out.printf(".");
					} j ==0 || j+1 == y j ==0 j 0 j+1 == y j+1 j 1 y {
						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
import java.io.*;
  
class Main{
	public static void main(String[] args) throws IOException{

		int x,y,i,j;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String[] str = br.readLine().split(" ");
			x = Integer.parseInt(str[0]);
			y = Integer.parseInt(str[1]);

			if(x == 0 && y ==0){
				break;
			}

			for(i = 0; i < x; i++){
				for(j = 0; j < y; j++){
					if(i == 0 || i+1 == x){
						System.out.printf("#");
					}else if(j ==0 || j+1 == y){
						System.out.printf("#");
					}else {
						System.out.printf(".");
					}
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		}
  	}
}