import java.io.*;
public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		while(true){
		String str=input.readLine();
		String[] arr=str.split(" ");
		int h=Integer.parseInt(arr[0]);	
		int w=Integer.parseInt(arr[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){
				sb.append("#");
				}else{
					sb.append(".");
				}
			}
				sb.append("\n");
		}
			sb.append("\n");

			}
		
		
		
		System.out.print(sb);
	}
} import java.io.*; io.* java public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		while(true){
		String str=input.readLine();
		String[] arr=str.split(" ");
		int h=Integer.parseInt(arr[0]);	
		int w=Integer.parseInt(arr[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){
				sb.append("#");
				}else{
					sb.append(".");
				}
			}
				sb.append("\n");
		}
			sb.append("\n");

			}
		
		
		
		System.out.print(sb);
	}
} Main public static void main(String[] args)throws Exception{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		while(true){
		String str=input.readLine();
		String[] arr=str.split(" ");
		int h=Integer.parseInt(arr[0]);	
		int w=Integer.parseInt(arr[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){
				sb.append("#");
				}else{
					sb.append(".");
				}
			}
				sb.append("\n");
		}
			sb.append("\n");

			}
		
		
		
		System.out.print(sb);
	} main {
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		while(true){
		String str=input.readLine();
		String[] arr=str.split(" ");
		int h=Integer.parseInt(arr[0]);	
		int w=Integer.parseInt(arr[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){
				sb.append("#");
				}else{
					sb.append(".");
				}
			}
				sb.append("\n");
		}
			sb.append("\n");

			}
		
		
		
		System.out.print(sb);
	} BufferedReader input=new BufferedReader(new InputStreamReader(System.in)); input new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb=new StringBuilder(); sb new StringBuilder() while(true){
		String str=input.readLine();
		String[] arr=str.split(" ");
		int h=Integer.parseInt(arr[0]);	
		int w=Integer.parseInt(arr[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){
				sb.append("#");
				}else{
					sb.append(".");
				}
			}
				sb.append("\n");
		}
			sb.append("\n");

			} true {
		String str=input.readLine();
		String[] arr=str.split(" ");
		int h=Integer.parseInt(arr[0]);	
		int w=Integer.parseInt(arr[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){
				sb.append("#");
				}else{
					sb.append(".");
				}
			}
				sb.append("\n");
		}
			sb.append("\n");

			} String str=input.readLine(); str input.readLine() input.readLine input String[] arr=str.split(" "); arr str.split(" ") str.split str " " int h=Integer.parseInt(arr[0]); h Integer.parseInt(arr[0]) Integer.parseInt Integer arr[0] arr 0 int w=Integer.parseInt(arr[1]); w Integer.parseInt(arr[1]) Integer.parseInt Integer arr[1] arr 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){
				sb.append("#");
				}else{
					sb.append(".");
				}
			}
				sb.append("\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){
				sb.append("#");
				}else{
					sb.append(".");
				}
			}
				sb.append("\n");
		} {

			for(int j=0;j<w;j++){
				if(i==0||i==h-1||j==0||j==w-1){
				sb.append("#");
				}else{
					sb.append(".");
				}
			}
				sb.append("\n");
		} for(int j=0;j<w;j++){
				if(i==0||i==h-1||j==0||j==w-1){
				sb.append("#");
				}else{
					sb.append(".");
				}
			} 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){
				sb.append("#");
				}else{
					sb.append(".");
				}
			} {
				if(i==0||i==h-1||j==0||j==w-1){
				sb.append("#");
				}else{
					sb.append(".");
				}
			} if(i==0||i==h-1||j==0||j==w-1){
				sb.append("#");
				}else{
					sb.append(".");
				} i==0||i==h-1||j==0||j==w-1 j==0 i==0||i==h-1||j==0||j==w-1 i==0 i 0 i==h-1 i h-1 h 1 j==0 j 0 j==w-1 j w-1 w 1 {
				sb.append("#");
				} sb.append("#") sb.append sb "#" {
					sb.append(".");
				} 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 public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		while(true){
		String str=input.readLine();
		String[] arr=str.split(" ");
		int h=Integer.parseInt(arr[0]);	
		int w=Integer.parseInt(arr[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){
				sb.append("#");
				}else{
					sb.append(".");
				}
			}
				sb.append("\n");
		}
			sb.append("\n");

			}
		
		
		
		System.out.print(sb);
	}
} public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		while(true){
		String str=input.readLine();
		String[] arr=str.split(" ");
		int h=Integer.parseInt(arr[0]);	
		int w=Integer.parseInt(arr[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){
				sb.append("#");
				}else{
					sb.append(".");
				}
			}
				sb.append("\n");
		}
			sb.append("\n");

			}
		
		
		
		System.out.print(sb);
	}
} Main
import java.io.*;
public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		while(true){
		String str=input.readLine();
		String[] arr=str.split(" ");
		int h=Integer.parseInt(arr[0]);	
		int w=Integer.parseInt(arr[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){
				sb.append("#");
				}else{
					sb.append(".");
				}
			}
				sb.append("\n");
		}
			sb.append("\n");

			}
		
		
		
		System.out.print(sb);
	}
}