public class Main {


		public static void main(String[] args) {
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int h, w, i, t;
		
while(true){
		h = scan.nextInt();
		w = scan.nextInt();
		
		if(h == 0 && w == 0){
				break;
			}
		if(3 <= h && h <= 300 && 3 <= w && w <= 300){
			for(i = 0; i < h ; i++){
			for(t = 0; t < w ; t++){
				if(t == 0 || t == w - 1 || i == 0 || i == h - 1){
				System.out.print("#");
				}else{
					
					System.out.print(".");
				}
			}System.out.println("");
			
			}System.out.println("");
		
		
		}
		
		}
		}
} public class Main {


		public static void main(String[] args) {
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int h, w, i, t;
		
while(true){
		h = scan.nextInt();
		w = scan.nextInt();
		
		if(h == 0 && w == 0){
				break;
			}
		if(3 <= h && h <= 300 && 3 <= w && w <= 300){
			for(i = 0; i < h ; i++){
			for(t = 0; t < w ; t++){
				if(t == 0 || t == w - 1 || i == 0 || i == h - 1){
				System.out.print("#");
				}else{
					
					System.out.print(".");
				}
			}System.out.println("");
			
			}System.out.println("");
		
		
		}
		
		}
		}
} Main public static void main(String[] args) {
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int h, w, i, t;
		
while(true){
		h = scan.nextInt();
		w = scan.nextInt();
		
		if(h == 0 && w == 0){
				break;
			}
		if(3 <= h && h <= 300 && 3 <= w && w <= 300){
			for(i = 0; i < h ; i++){
			for(t = 0; t < w ; t++){
				if(t == 0 || t == w - 1 || i == 0 || i == h - 1){
				System.out.print("#");
				}else{
					
					System.out.print(".");
				}
			}System.out.println("");
			
			}System.out.println("");
		
		
		}
		
		}
		} main {
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int h, w, i, t;
		
while(true){
		h = scan.nextInt();
		w = scan.nextInt();
		
		if(h == 0 && w == 0){
				break;
			}
		if(3 <= h && h <= 300 && 3 <= w && w <= 300){
			for(i = 0; i < h ; i++){
			for(t = 0; t < w ; t++){
				if(t == 0 || t == w - 1 || i == 0 || i == h - 1){
				System.out.print("#");
				}else{
					
					System.out.print(".");
				}
			}System.out.println("");
			
			}System.out.println("");
		
		
		}
		
		}
		} java.util.Scanner scan = new java.util.Scanner(System.in); scan new java.util.Scanner(System.in) int h h w w i i t; t while(true){
		h = scan.nextInt();
		w = scan.nextInt();
		
		if(h == 0 && w == 0){
				break;
			}
		if(3 <= h && h <= 300 && 3 <= w && w <= 300){
			for(i = 0; i < h ; i++){
			for(t = 0; t < w ; t++){
				if(t == 0 || t == w - 1 || i == 0 || i == h - 1){
				System.out.print("#");
				}else{
					
					System.out.print(".");
				}
			}System.out.println("");
			
			}System.out.println("");
		
		
		}
		
		} true {
		h = scan.nextInt();
		w = scan.nextInt();
		
		if(h == 0 && w == 0){
				break;
			}
		if(3 <= h && h <= 300 && 3 <= w && w <= 300){
			for(i = 0; i < h ; i++){
			for(t = 0; t < w ; t++){
				if(t == 0 || t == w - 1 || i == 0 || i == h - 1){
				System.out.print("#");
				}else{
					
					System.out.print(".");
				}
			}System.out.println("");
			
			}System.out.println("");
		
		
		}
		
		} h = scan.nextInt() h scan.nextInt() scan.nextInt scan w = scan.nextInt() w scan.nextInt() scan.nextInt scan if(h == 0 && w == 0){
				break;
			} h == 0 && w == 0 h == 0 h 0 w == 0 w 0 {
				break;
			} break; if(3 <= h && h <= 300 && 3 <= w && w <= 300){
			for(i = 0; i < h ; i++){
			for(t = 0; t < w ; t++){
				if(t == 0 || t == w - 1 || i == 0 || i == h - 1){
				System.out.print("#");
				}else{
					
					System.out.print(".");
				}
			}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(i = 0; i < h ; i++){
			for(t = 0; t < w ; t++){
				if(t == 0 || t == w - 1 || i == 0 || i == h - 1){
				System.out.print("#");
				}else{
					
					System.out.print(".");
				}
			}System.out.println("");
			
			}System.out.println("");
		
		
		} for(i = 0; i < h ; i++){
			for(t = 0; t < w ; t++){
				if(t == 0 || t == w - 1 || i == 0 || i == h - 1){
				System.out.print("#");
				}else{
					
					System.out.print(".");
				}
			}System.out.println("");
			
			} i = 0; i = 0 i 0 i < h i h i++ i++ i {
			for(t = 0; t < w ; t++){
				if(t == 0 || t == w - 1 || i == 0 || i == h - 1){
				System.out.print("#");
				}else{
					
					System.out.print(".");
				}
			}System.out.println("");
			
			} {
			for(t = 0; t < w ; t++){
				if(t == 0 || t == w - 1 || i == 0 || i == h - 1){
				System.out.print("#");
				}else{
					
					System.out.print(".");
				}
			}System.out.println("");
			
			} for(t = 0; t < w ; t++){
				if(t == 0 || t == w - 1 || i == 0 || i == h - 1){
				System.out.print("#");
				}else{
					
					System.out.print(".");
				}
			} t = 0; t = 0 t 0 t < w t w t++ t++ t {
				if(t == 0 || t == w - 1 || i == 0 || i == h - 1){
				System.out.print("#");
				}else{
					
					System.out.print(".");
				}
			} {
				if(t == 0 || t == w - 1 || i == 0 || i == h - 1){
				System.out.print("#");
				}else{
					
					System.out.print(".");
				}
			} if(t == 0 || t == w - 1 || i == 0 || i == h - 1){
				System.out.print("#");
				}else{
					
					System.out.print(".");
				} t == 0 || t == w - 1 || i == 0 || i == h - 1 i == 0 t == 0 || t == w - 1 || i == 0 || i == h - 1 t == 0 t 0 t == w - 1 t w - 1 w 1 i == 0 i 0 i == h - 1 i h - 1 h 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 "" System.out.println("") System.out.println System.out System System.out "" String[] args args public class Main {


		public static void main(String[] args) {
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int h, w, i, t;
		
while(true){
		h = scan.nextInt();
		w = scan.nextInt();
		
		if(h == 0 && w == 0){
				break;
			}
		if(3 <= h && h <= 300 && 3 <= w && w <= 300){
			for(i = 0; i < h ; i++){
			for(t = 0; t < w ; t++){
				if(t == 0 || t == w - 1 || i == 0 || i == h - 1){
				System.out.print("#");
				}else{
					
					System.out.print(".");
				}
			}System.out.println("");
			
			}System.out.println("");
		
		
		}
		
		}
		}
} public class Main {


		public static void main(String[] args) {
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int h, w, i, t;
		
while(true){
		h = scan.nextInt();
		w = scan.nextInt();
		
		if(h == 0 && w == 0){
				break;
			}
		if(3 <= h && h <= 300 && 3 <= w && w <= 300){
			for(i = 0; i < h ; i++){
			for(t = 0; t < w ; t++){
				if(t == 0 || t == w - 1 || i == 0 || i == h - 1){
				System.out.print("#");
				}else{
					
					System.out.print(".");
				}
			}System.out.println("");
			
			}System.out.println("");
		
		
		}
		
		}
		}
} Main
public class Main {


		public static void main(String[] args) {
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int h, w, i, t;
		
while(true){
		h = scan.nextInt();
		w = scan.nextInt();
		
		if(h == 0 && w == 0){
				break;
			}
		if(3 <= h && h <= 300 && 3 <= w && w <= 300){
			for(i = 0; i < h ; i++){
			for(t = 0; t < w ; t++){
				if(t == 0 || t == w - 1 || i == 0 || i == h - 1){
				System.out.print("#");
				}else{
					
					System.out.print(".");
				}
			}System.out.println("");
			
			}System.out.println("");
		
		
		}
		
		}
		}
}