import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main {
    public static void main(String[] args) {

    	try{
    		InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);

			while(true){
				String buf = br.readLine();
				StringTokenizer st=new StringTokenizer(buf," ");
				int H = Integer.parseInt(st.nextToken());
				int W = Integer.parseInt(st.nextToken());

				if(W==0 && H==0)	break;
				if(H>=300 && W>=300)	break;;
				for(int i=1;i<=H;i++){
					for(int j=1;j <= W;j++){
						if(i>1 && i<H && j>1 && j<W)	System.out.print(".");
						else
						System.out.print("#");
					}
				System.out.println();
				}
				System.out.println();
			}
		} catch(IOException e) {
    		System.err.println(e);
		}
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util public class Main {
    public static void main(String[] args) {

    	try{
    		InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);

			while(true){
				String buf = br.readLine();
				StringTokenizer st=new StringTokenizer(buf," ");
				int H = Integer.parseInt(st.nextToken());
				int W = Integer.parseInt(st.nextToken());

				if(W==0 && H==0)	break;
				if(H>=300 && W>=300)	break;;
				for(int i=1;i<=H;i++){
					for(int j=1;j <= W;j++){
						if(i>1 && i<H && j>1 && j<W)	System.out.print(".");
						else
						System.out.print("#");
					}
				System.out.println();
				}
				System.out.println();
			}
		} catch(IOException e) {
    		System.err.println(e);
		}
    }
} Main public static void main(String[] args) {

    	try{
    		InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);

			while(true){
				String buf = br.readLine();
				StringTokenizer st=new StringTokenizer(buf," ");
				int H = Integer.parseInt(st.nextToken());
				int W = Integer.parseInt(st.nextToken());

				if(W==0 && H==0)	break;
				if(H>=300 && W>=300)	break;;
				for(int i=1;i<=H;i++){
					for(int j=1;j <= W;j++){
						if(i>1 && i<H && j>1 && j<W)	System.out.print(".");
						else
						System.out.print("#");
					}
				System.out.println();
				}
				System.out.println();
			}
		} catch(IOException e) {
    		System.err.println(e);
		}
    } main {

    	try{
    		InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);

			while(true){
				String buf = br.readLine();
				StringTokenizer st=new StringTokenizer(buf," ");
				int H = Integer.parseInt(st.nextToken());
				int W = Integer.parseInt(st.nextToken());

				if(W==0 && H==0)	break;
				if(H>=300 && W>=300)	break;;
				for(int i=1;i<=H;i++){
					for(int j=1;j <= W;j++){
						if(i>1 && i<H && j>1 && j<W)	System.out.print(".");
						else
						System.out.print("#");
					}
				System.out.println();
				}
				System.out.println();
			}
		} catch(IOException e) {
    		System.err.println(e);
		}
    } try{
    		InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);

			while(true){
				String buf = br.readLine();
				StringTokenizer st=new StringTokenizer(buf," ");
				int H = Integer.parseInt(st.nextToken());
				int W = Integer.parseInt(st.nextToken());

				if(W==0 && H==0)	break;
				if(H>=300 && W>=300)	break;;
				for(int i=1;i<=H;i++){
					for(int j=1;j <= W;j++){
						if(i>1 && i<H && j>1 && j<W)	System.out.print(".");
						else
						System.out.print("#");
					}
				System.out.println();
				}
				System.out.println();
			}
		} catch(IOException e) {
    		System.err.println(e);
		} catch(IOException e) {
    		System.err.println(e);
		} IOException e {
    		System.err.println(e);
		} System.err.println(e) System.err.println System.err System System.err e {
    		InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);

			while(true){
				String buf = br.readLine();
				StringTokenizer st=new StringTokenizer(buf," ");
				int H = Integer.parseInt(st.nextToken());
				int W = Integer.parseInt(st.nextToken());

				if(W==0 && H==0)	break;
				if(H>=300 && W>=300)	break;;
				for(int i=1;i<=H;i++){
					for(int j=1;j <= W;j++){
						if(i>1 && i<H && j>1 && j<W)	System.out.print(".");
						else
						System.out.print("#");
					}
				System.out.println();
				}
				System.out.println();
			}
		} InputStreamReader isr = new InputStreamReader(System.in); isr new InputStreamReader(System.in) BufferedReader br = new BufferedReader(isr); br new BufferedReader(isr) while(true){
				String buf = br.readLine();
				StringTokenizer st=new StringTokenizer(buf," ");
				int H = Integer.parseInt(st.nextToken());
				int W = Integer.parseInt(st.nextToken());

				if(W==0 && H==0)	break;
				if(H>=300 && W>=300)	break;;
				for(int i=1;i<=H;i++){
					for(int j=1;j <= W;j++){
						if(i>1 && i<H && j>1 && j<W)	System.out.print(".");
						else
						System.out.print("#");
					}
				System.out.println();
				}
				System.out.println();
			} true {
				String buf = br.readLine();
				StringTokenizer st=new StringTokenizer(buf," ");
				int H = Integer.parseInt(st.nextToken());
				int W = Integer.parseInt(st.nextToken());

				if(W==0 && H==0)	break;
				if(H>=300 && W>=300)	break;;
				for(int i=1;i<=H;i++){
					for(int j=1;j <= W;j++){
						if(i>1 && i<H && j>1 && j<W)	System.out.print(".");
						else
						System.out.print("#");
					}
				System.out.println();
				}
				System.out.println();
			} String buf = br.readLine(); buf br.readLine() br.readLine br StringTokenizer st=new StringTokenizer(buf," "); st new StringTokenizer(buf," ") int H = Integer.parseInt(st.nextToken()); H Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st int W = Integer.parseInt(st.nextToken()); W Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st if(W==0 && H==0)	break; W==0 && H==0 W==0 W 0 H==0 H 0 break; if(H>=300 && W>=300)	break; H>=300 && W>=300 H>=300 H 300 W>=300 W 300 break; for(int i=1;i<=H;i++){
					for(int j=1;j <= W;j++){
						if(i>1 && i<H && j>1 && j<W)	System.out.print(".");
						else
						System.out.print("#");
					}
				System.out.println();
				} int i=1; int i=1; i 1 i<=H i H i++ i++ i {
					for(int j=1;j <= W;j++){
						if(i>1 && i<H && j>1 && j<W)	System.out.print(".");
						else
						System.out.print("#");
					}
				System.out.println();
				} {
					for(int j=1;j <= W;j++){
						if(i>1 && i<H && j>1 && j<W)	System.out.print(".");
						else
						System.out.print("#");
					}
				System.out.println();
				} for(int j=1;j <= W;j++){
						if(i>1 && i<H && j>1 && j<W)	System.out.print(".");
						else
						System.out.print("#");
					} int j=1; int j=1; j 1 j <= W j W j++ j++ j {
						if(i>1 && i<H && j>1 && j<W)	System.out.print(".");
						else
						System.out.print("#");
					} {
						if(i>1 && i<H && j>1 && j<W)	System.out.print(".");
						else
						System.out.print("#");
					} if(i>1 && i<H && j>1 && j<W)	System.out.print(".");
						else
						System.out.print("#"); i>1 && i<H && j>1 && j<W j>1 i>1 && i<H && j>1 && j<W i>1 i 1 i<H i H j>1 j 1 j<W j W 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 String[] args args public class Main {
    public static void main(String[] args) {

    	try{
    		InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);

			while(true){
				String buf = br.readLine();
				StringTokenizer st=new StringTokenizer(buf," ");
				int H = Integer.parseInt(st.nextToken());
				int W = Integer.parseInt(st.nextToken());

				if(W==0 && H==0)	break;
				if(H>=300 && W>=300)	break;;
				for(int i=1;i<=H;i++){
					for(int j=1;j <= W;j++){
						if(i>1 && i<H && j>1 && j<W)	System.out.print(".");
						else
						System.out.print("#");
					}
				System.out.println();
				}
				System.out.println();
			}
		} catch(IOException e) {
    		System.err.println(e);
		}
    }
} public class Main {
    public static void main(String[] args) {

    	try{
    		InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);

			while(true){
				String buf = br.readLine();
				StringTokenizer st=new StringTokenizer(buf," ");
				int H = Integer.parseInt(st.nextToken());
				int W = Integer.parseInt(st.nextToken());

				if(W==0 && H==0)	break;
				if(H>=300 && W>=300)	break;;
				for(int i=1;i<=H;i++){
					for(int j=1;j <= W;j++){
						if(i>1 && i<H && j>1 && j<W)	System.out.print(".");
						else
						System.out.print("#");
					}
				System.out.println();
				}
				System.out.println();
			}
		} catch(IOException e) {
    		System.err.println(e);
		}
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main {
    public static void main(String[] args) {

    	try{
    		InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);

			while(true){
				String buf = br.readLine();
				StringTokenizer st=new StringTokenizer(buf," ");
				int H = Integer.parseInt(st.nextToken());
				int W = Integer.parseInt(st.nextToken());

				if(W==0 && H==0)	break;
				if(H>=300 && W>=300)	break;;
				for(int i=1;i<=H;i++){
					for(int j=1;j <= W;j++){
						if(i>1 && i<H && j>1 && j<W)	System.out.print(".");
						else
						System.out.print("#");
					}
				System.out.println();
				}
				System.out.println();
			}
		} catch(IOException e) {
    		System.err.println(e);
		}
    }
}