import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main {
    public static void main(String[] args) throws Exception{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line = null;
            while((line = br.readLine()) != null){
            	String lines[] = line.split(" ");
            	int height = Integer.parseInt(lines[0]);
            	int width = Integer.parseInt(lines[1]);

            	if(height==0||width==0)break;
            	for(int i=0;i<height;i++){
            		for(int j=0; j<width; j++){
            			if(i==0 || i==height-1){
            				System.out.print("#");
            			}else{
            				System.out.print((j==0 || j==width-1) ? "#" : ".");
            			}
            		}
            		System.out.println("");
            	}
            	System.out.println("");
            }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io class Main {
    public static void main(String[] args) throws Exception{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line = null;
            while((line = br.readLine()) != null){
            	String lines[] = line.split(" ");
            	int height = Integer.parseInt(lines[0]);
            	int width = Integer.parseInt(lines[1]);

            	if(height==0||width==0)break;
            	for(int i=0;i<height;i++){
            		for(int j=0; j<width; j++){
            			if(i==0 || i==height-1){
            				System.out.print("#");
            			}else{
            				System.out.print((j==0 || j==width-1) ? "#" : ".");
            			}
            		}
            		System.out.println("");
            	}
            	System.out.println("");
            }
    }
} Main public static void main(String[] args) throws Exception{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line = null;
            while((line = br.readLine()) != null){
            	String lines[] = line.split(" ");
            	int height = Integer.parseInt(lines[0]);
            	int width = Integer.parseInt(lines[1]);

            	if(height==0||width==0)break;
            	for(int i=0;i<height;i++){
            		for(int j=0; j<width; j++){
            			if(i==0 || i==height-1){
            				System.out.print("#");
            			}else{
            				System.out.print((j==0 || j==width-1) ? "#" : ".");
            			}
            		}
            		System.out.println("");
            	}
            	System.out.println("");
            }
    } main {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line = null;
            while((line = br.readLine()) != null){
            	String lines[] = line.split(" ");
            	int height = Integer.parseInt(lines[0]);
            	int width = Integer.parseInt(lines[1]);

            	if(height==0||width==0)break;
            	for(int i=0;i<height;i++){
            		for(int j=0; j<width; j++){
            			if(i==0 || i==height-1){
            				System.out.print("#");
            			}else{
            				System.out.print((j==0 || j==width-1) ? "#" : ".");
            			}
            		}
            		System.out.println("");
            	}
            	System.out.println("");
            }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String line = null; line null while((line = br.readLine()) != null){
            	String lines[] = line.split(" ");
            	int height = Integer.parseInt(lines[0]);
            	int width = Integer.parseInt(lines[1]);

            	if(height==0||width==0)break;
            	for(int i=0;i<height;i++){
            		for(int j=0; j<width; j++){
            			if(i==0 || i==height-1){
            				System.out.print("#");
            			}else{
            				System.out.print((j==0 || j==width-1) ? "#" : ".");
            			}
            		}
            		System.out.println("");
            	}
            	System.out.println("");
            } (line = br.readLine()) != null (line = br.readLine()) line br.readLine() br.readLine br null {
            	String lines[] = line.split(" ");
            	int height = Integer.parseInt(lines[0]);
            	int width = Integer.parseInt(lines[1]);

            	if(height==0||width==0)break;
            	for(int i=0;i<height;i++){
            		for(int j=0; j<width; j++){
            			if(i==0 || i==height-1){
            				System.out.print("#");
            			}else{
            				System.out.print((j==0 || j==width-1) ? "#" : ".");
            			}
            		}
            		System.out.println("");
            	}
            	System.out.println("");
            } String lines[] = line.split(" "); lines line.split(" ") line.split line " " int height = Integer.parseInt(lines[0]); height Integer.parseInt(lines[0]) Integer.parseInt Integer lines[0] lines 0 int width = Integer.parseInt(lines[1]); width Integer.parseInt(lines[1]) Integer.parseInt Integer lines[1] lines 1 if(height==0||width==0)break; height==0||width==0 height==0 height 0 width==0 width 0 break; for(int i=0;i<height;i++){
            		for(int j=0; j<width; j++){
            			if(i==0 || i==height-1){
            				System.out.print("#");
            			}else{
            				System.out.print((j==0 || j==width-1) ? "#" : ".");
            			}
            		}
            		System.out.println("");
            	} int i=0; int i=0; i 0 i<height i height i++ i++ i {
            		for(int j=0; j<width; j++){
            			if(i==0 || i==height-1){
            				System.out.print("#");
            			}else{
            				System.out.print((j==0 || j==width-1) ? "#" : ".");
            			}
            		}
            		System.out.println("");
            	} {
            		for(int j=0; j<width; j++){
            			if(i==0 || i==height-1){
            				System.out.print("#");
            			}else{
            				System.out.print((j==0 || j==width-1) ? "#" : ".");
            			}
            		}
            		System.out.println("");
            	} for(int j=0; j<width; j++){
            			if(i==0 || i==height-1){
            				System.out.print("#");
            			}else{
            				System.out.print((j==0 || j==width-1) ? "#" : ".");
            			}
            		} int j=0; int j=0; j 0 j<width j width j++ j++ j {
            			if(i==0 || i==height-1){
            				System.out.print("#");
            			}else{
            				System.out.print((j==0 || j==width-1) ? "#" : ".");
            			}
            		} {
            			if(i==0 || i==height-1){
            				System.out.print("#");
            			}else{
            				System.out.print((j==0 || j==width-1) ? "#" : ".");
            			}
            		} if(i==0 || i==height-1){
            				System.out.print("#");
            			}else{
            				System.out.print((j==0 || j==width-1) ? "#" : ".");
            			} i==0 || i==height-1 i==0 i 0 i==height-1 i height-1 height 1 {
            				System.out.print("#");
            			} System.out.print("#") System.out.print System.out System System.out "#" {
            				System.out.print((j==0 || j==width-1) ? "#" : ".");
            			} System.out.print((j==0 || j==width-1) ? "#" : ".") System.out.print System.out System System.out (j==0 || j==width-1) ? "#" : "." (j==0 || j==width-1) j==0 j 0 j==width-1 j width-1 width 1 "#" "." 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
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main {
    public static void main(String[] args) throws Exception{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line = null;
            while((line = br.readLine()) != null){
            	String lines[] = line.split(" ");
            	int height = Integer.parseInt(lines[0]);
            	int width = Integer.parseInt(lines[1]);

            	if(height==0||width==0)break;
            	for(int i=0;i<height;i++){
            		for(int j=0; j<width; j++){
            			if(i==0 || i==height-1){
            				System.out.print("#");
            			}else{
            				System.out.print((j==0 || j==width-1) ? "#" : ".");
            			}
            		}
            		System.out.println("");
            	}
            	System.out.println("");
            }
    }
}