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

	public class Main {
	    public static void main(String[] args) throws Exception {
	        // Here your code !
	        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	        while(true) {
		        String line = br.readLine();
		        String[] line2 = line.split(" ");
		        if(Integer.parseInt(line2[0])==0)
		        	if(Integer.parseInt(line2[1]) == 0)
		        		break;
		        print(Integer.parseInt(line2[0]),Integer.parseInt(line2[1]));
	        }
	    }
	    static void print(int w,int h) {
	    		for(int j=0;j < w;j++) {
	    	    	for(int i=0;i < h;i++) {
	    	    	    if(j==0 || j==w-1 || i==0 || i==h-1)
    	    	    		System.out.print("#");
    	    	    	else
    	    	    		System.out.print(".");
	    	    	}
		    		System.out.println();
	    		}
	    		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 {
	        // Here your code !
	        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	        while(true) {
		        String line = br.readLine();
		        String[] line2 = line.split(" ");
		        if(Integer.parseInt(line2[0])==0)
		        	if(Integer.parseInt(line2[1]) == 0)
		        		break;
		        print(Integer.parseInt(line2[0]),Integer.parseInt(line2[1]));
	        }
	    }
	    static void print(int w,int h) {
	    		for(int j=0;j < w;j++) {
	    	    	for(int i=0;i < h;i++) {
	    	    	    if(j==0 || j==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) throws Exception {
	        // Here your code !
	        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	        while(true) {
		        String line = br.readLine();
		        String[] line2 = line.split(" ");
		        if(Integer.parseInt(line2[0])==0)
		        	if(Integer.parseInt(line2[1]) == 0)
		        		break;
		        print(Integer.parseInt(line2[0]),Integer.parseInt(line2[1]));
	        }
	    } main {
	        // Here your code !
	        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	        while(true) {
		        String line = br.readLine();
		        String[] line2 = line.split(" ");
		        if(Integer.parseInt(line2[0])==0)
		        	if(Integer.parseInt(line2[1]) == 0)
		        		break;
		        print(Integer.parseInt(line2[0]),Integer.parseInt(line2[1]));
	        }
	    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true) {
		        String line = br.readLine();
		        String[] line2 = line.split(" ");
		        if(Integer.parseInt(line2[0])==0)
		        	if(Integer.parseInt(line2[1]) == 0)
		        		break;
		        print(Integer.parseInt(line2[0]),Integer.parseInt(line2[1]));
	        } true {
		        String line = br.readLine();
		        String[] line2 = line.split(" ");
		        if(Integer.parseInt(line2[0])==0)
		        	if(Integer.parseInt(line2[1]) == 0)
		        		break;
		        print(Integer.parseInt(line2[0]),Integer.parseInt(line2[1]));
	        } String line = br.readLine(); line br.readLine() br.readLine br String[] line2 = line.split(" "); line2 line.split(" ") line.split line " " if(Integer.parseInt(line2[0])==0)
		        	if(Integer.parseInt(line2[1]) == 0)
		        		break; Integer.parseInt(line2[0])==0 Integer.parseInt(line2[0]) Integer.parseInt Integer line2[0] line2 0 0 if(Integer.parseInt(line2[1]) == 0)
		        		break; Integer.parseInt(line2[1]) == 0 Integer.parseInt(line2[1]) Integer.parseInt Integer line2[1] line2 1 0 break; print(Integer.parseInt(line2[0]),Integer.parseInt(line2[1])) print Integer.parseInt(line2[0]) Integer.parseInt Integer line2[0] line2 0 Integer.parseInt(line2[1]) Integer.parseInt Integer line2[1] line2 1 String[] args args static void print(int w,int h) {
	    		for(int j=0;j < w;j++) {
	    	    	for(int i=0;i < h;i++) {
	    	    	    if(j==0 || j==w-1 || i==0 || i==h-1)
    	    	    		System.out.print("#");
    	    	    	else
    	    	    		System.out.print(".");
	    	    	}
		    		System.out.println();
	    		}
	    		System.out.println();
	    } print {
	    		for(int j=0;j < w;j++) {
	    	    	for(int i=0;i < h;i++) {
	    	    	    if(j==0 || j==w-1 || i==0 || i==h-1)
    	    	    		System.out.print("#");
    	    	    	else
    	    	    		System.out.print(".");
	    	    	}
		    		System.out.println();
	    		}
	    		System.out.println();
	    } for(int j=0;j < w;j++) {
	    	    	for(int i=0;i < h;i++) {
	    	    	    if(j==0 || j==w-1 || i==0 || i==h-1)
    	    	    		System.out.print("#");
    	    	    	else
    	    	    		System.out.print(".");
	    	    	}
		    		System.out.println();
	    		} int j=0; int j=0; j 0 j < w j w j++ j++ j {
	    	    	for(int i=0;i < h;i++) {
	    	    	    if(j==0 || j==w-1 || i==0 || i==h-1)
    	    	    		System.out.print("#");
    	    	    	else
    	    	    		System.out.print(".");
	    	    	}
		    		System.out.println();
	    		} {
	    	    	for(int i=0;i < h;i++) {
	    	    	    if(j==0 || j==w-1 || i==0 || i==h-1)
    	    	    		System.out.print("#");
    	    	    	else
    	    	    		System.out.print(".");
	    	    	}
		    		System.out.println();
	    		} for(int i=0;i < h;i++) {
	    	    	    if(j==0 || j==w-1 || i==0 || i==h-1)
    	    	    		System.out.print("#");
    	    	    	else
    	    	    		System.out.print(".");
	    	    	} int i=0; int i=0; i 0 i < h i h i++ i++ i {
	    	    	    if(j==0 || j==w-1 || i==0 || i==h-1)
    	    	    		System.out.print("#");
    	    	    	else
    	    	    		System.out.print(".");
	    	    	} {
	    	    	    if(j==0 || j==w-1 || i==0 || i==h-1)
    	    	    		System.out.print("#");
    	    	    	else
    	    	    		System.out.print(".");
	    	    	} if(j==0 || j==w-1 || i==0 || i==h-1)
    	    	    		System.out.print("#");
    	    	    	else
    	    	    		System.out.print("."); j==0 || j==w-1 || i==0 || i==h-1 i==0 j==0 || j==w-1 || i==0 || i==h-1 j==0 j 0 j==w-1 j w-1 w 1 i==0 i 0 i==h-1 i h-1 h 1 System.out.print("#") System.out.print System.out System System.out "#" 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 int w w int h h public class Main {
	    public static void main(String[] args) throws Exception {
	        // Here your code !
	        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	        while(true) {
		        String line = br.readLine();
		        String[] line2 = line.split(" ");
		        if(Integer.parseInt(line2[0])==0)
		        	if(Integer.parseInt(line2[1]) == 0)
		        		break;
		        print(Integer.parseInt(line2[0]),Integer.parseInt(line2[1]));
	        }
	    }
	    static void print(int w,int h) {
	    		for(int j=0;j < w;j++) {
	    	    	for(int i=0;i < h;i++) {
	    	    	    if(j==0 || j==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) throws Exception {
	        // Here your code !
	        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	        while(true) {
		        String line = br.readLine();
		        String[] line2 = line.split(" ");
		        if(Integer.parseInt(line2[0])==0)
		        	if(Integer.parseInt(line2[1]) == 0)
		        		break;
		        print(Integer.parseInt(line2[0]),Integer.parseInt(line2[1]));
	        }
	    }
	    static void print(int w,int h) {
	    		for(int j=0;j < w;j++) {
	    	    	for(int i=0;i < h;i++) {
	    	    	    if(j==0 || j==w-1 || i==0 || i==h-1)
    	    	    		System.out.print("#");
    	    	    	else
    	    	    		System.out.print(".");
	    	    	}
		    		System.out.println();
	    		}
	    		System.out.println();
	    }
	} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

	public class Main {
	    public static void main(String[] args) throws Exception {
	        // Here your code !
	        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	        while(true) {
		        String line = br.readLine();
		        String[] line2 = line.split(" ");
		        if(Integer.parseInt(line2[0])==0)
		        	if(Integer.parseInt(line2[1]) == 0)
		        		break;
		        print(Integer.parseInt(line2[0]),Integer.parseInt(line2[1]));
	        }
	    }
	    static void print(int w,int h) {
	    		for(int j=0;j < w;j++) {
	    	    	for(int i=0;i < h;i++) {
	    	    	    if(j==0 || j==w-1 || i==0 || i==h-1)
    	    	    		System.out.print("#");
    	    	    	else
    	    	    		System.out.print(".");
	    	    	}
		    		System.out.println();
	    		}
	    		System.out.println();
	    }
	}