import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 * ??\????????????????????????H cm ?????? W cm ???????????????????????°?????????????????????????????????

##########
#........#
#........#
#........#
#........#
##########
?????????????????? 6 cm ?????? 10 cm ???????????¨??????????????????

 * @author wsKmatsuda
 *
 */
public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	public void run(){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String inputData;
        List<Square> squareList = new ArrayList<Square>();
        try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
	            if("0 0".equals(inputData)){
	            	break;
	            }else{
					String[] strNumber = inputData.split(" ");
					int h = Integer.parseInt(strNumber[0]);
					int w = Integer.parseInt(strNumber[1]);
					squareList.add(new Square(h,w));
	            }
	        }

	        //??????
	        for(Square square : squareList){
				outputSquare(square.h , square.w);
				System.out.println();
	        }

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	/**
	 * ????????¢?????????
	 * @param h
	 * @param w
	 */
	private void outputSquare(int h, int w) {
		StringBuilder sbLine = new StringBuilder();
		StringBuilder sbLineFastLast = new StringBuilder();
		for(int i=0;i < w ;i++){
			sbLineFastLast.append("#");
			if(i == 0 || i == w - 1){
				sbLine.append("#");
			}
			else
			{
				sbLine.append(".");
			}
		}
		for(int i=0;i < h;i++){
			if(i==0 || i == h-1){
				System.out.println(sbLineFastLast.toString());
			}else{
				System.out.println(sbLine.toString());
			}
		}
	}

	/**
	 * ????§???¢?????????
	 * h,w???????????????
	 * ??????Inner??????????????????????????§????????????????????§?????????
	 *   ?????????????????????????????§?????¬????????????????????????????????¨?????????
	 *   AOJ??????Main??????????????????submit???????????????
	 *   ?????????????????£????????§Inner?????????????????????????????????
	 */
	class Square{

		public int h;
		public int w;

		Square(int _h ,int _w){
			h = _h;
			w = _w;
		}
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	public void run(){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String inputData;
        List<Square> squareList = new ArrayList<Square>();
        try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
	            if("0 0".equals(inputData)){
	            	break;
	            }else{
					String[] strNumber = inputData.split(" ");
					int h = Integer.parseInt(strNumber[0]);
					int w = Integer.parseInt(strNumber[1]);
					squareList.add(new Square(h,w));
	            }
	        }

	        //??????
	        for(Square square : squareList){
				outputSquare(square.h , square.w);
				System.out.println();
	        }

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	/**
	 * ????????¢?????????
	 * @param h
	 * @param w
	 */
	private void outputSquare(int h, int w) {
		StringBuilder sbLine = new StringBuilder();
		StringBuilder sbLineFastLast = new StringBuilder();
		for(int i=0;i < w ;i++){
			sbLineFastLast.append("#");
			if(i == 0 || i == w - 1){
				sbLine.append("#");
			}
			else
			{
				sbLine.append(".");
			}
		}
		for(int i=0;i < h;i++){
			if(i==0 || i == h-1){
				System.out.println(sbLineFastLast.toString());
			}else{
				System.out.println(sbLine.toString());
			}
		}
	}

	/**
	 * ????§???¢?????????
	 * h,w???????????????
	 * ??????Inner??????????????????????????§????????????????????§?????????
	 *   ?????????????????????????????§?????¬????????????????????????????????¨?????????
	 *   AOJ??????Main??????????????????submit???????????????
	 *   ?????????????????£????????§Inner?????????????????????????????????
	 */
	class Square{

		public int h;
		public int w;

		Square(int _h ,int _w){
			h = _h;
			w = _w;
		}
	}

} Main public static void main(String[] args) {
		new Main().run();
	} main {
		new Main().run();
	} new Main().run() new Main().run new Main() String[] args args public void run(){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String inputData;
        List<Square> squareList = new ArrayList<Square>();
        try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
	            if("0 0".equals(inputData)){
	            	break;
	            }else{
					String[] strNumber = inputData.split(" ");
					int h = Integer.parseInt(strNumber[0]);
					int w = Integer.parseInt(strNumber[1]);
					squareList.add(new Square(h,w));
	            }
	        }

	        //??????
	        for(Square square : squareList){
				outputSquare(square.h , square.w);
				System.out.println();
	        }

		} catch (IOException e) {
			e.printStackTrace();
		}

	} run {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String inputData;
        List<Square> squareList = new ArrayList<Square>();
        try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
	            if("0 0".equals(inputData)){
	            	break;
	            }else{
					String[] strNumber = inputData.split(" ");
					int h = Integer.parseInt(strNumber[0]);
					int w = Integer.parseInt(strNumber[1]);
					squareList.add(new Square(h,w));
	            }
	        }

	        //??????
	        for(Square square : squareList){
				outputSquare(square.h , square.w);
				System.out.println();
	        }

		} catch (IOException e) {
			e.printStackTrace();
		}

	} BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) String inputData; inputData List<Square> squareList = new ArrayList<Square>(); squareList new ArrayList<Square>() try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
	            if("0 0".equals(inputData)){
	            	break;
	            }else{
					String[] strNumber = inputData.split(" ");
					int h = Integer.parseInt(strNumber[0]);
					int w = Integer.parseInt(strNumber[1]);
					squareList.add(new Square(h,w));
	            }
	        }

	        //??????
	        for(Square square : squareList){
				outputSquare(square.h , square.w);
				System.out.println();
	        }

		} catch (IOException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
        	//??\???
	        while(true){
				inputData = reader.readLine();
	            if("0 0".equals(inputData)){
	            	break;
	            }else{
					String[] strNumber = inputData.split(" ");
					int h = Integer.parseInt(strNumber[0]);
					int w = Integer.parseInt(strNumber[1]);
					squareList.add(new Square(h,w));
	            }
	        }

	        //??????
	        for(Square square : squareList){
				outputSquare(square.h , square.w);
				System.out.println();
	        }

		} while(true){
				inputData = reader.readLine();
	            if("0 0".equals(inputData)){
	            	break;
	            }else{
					String[] strNumber = inputData.split(" ");
					int h = Integer.parseInt(strNumber[0]);
					int w = Integer.parseInt(strNumber[1]);
					squareList.add(new Square(h,w));
	            }
	        } true {
				inputData = reader.readLine();
	            if("0 0".equals(inputData)){
	            	break;
	            }else{
					String[] strNumber = inputData.split(" ");
					int h = Integer.parseInt(strNumber[0]);
					int w = Integer.parseInt(strNumber[1]);
					squareList.add(new Square(h,w));
	            }
	        } inputData = reader.readLine() inputData reader.readLine() reader.readLine reader if("0 0".equals(inputData)){
	            	break;
	            }else{
					String[] strNumber = inputData.split(" ");
					int h = Integer.parseInt(strNumber[0]);
					int w = Integer.parseInt(strNumber[1]);
					squareList.add(new Square(h,w));
	            } "0 0".equals(inputData) "0 0".equals "0 0" inputData {
	            	break;
	            } break; {
					String[] strNumber = inputData.split(" ");
					int h = Integer.parseInt(strNumber[0]);
					int w = Integer.parseInt(strNumber[1]);
					squareList.add(new Square(h,w));
	            } String[] strNumber = inputData.split(" "); strNumber inputData.split(" ") inputData.split inputData " " int h = Integer.parseInt(strNumber[0]); h Integer.parseInt(strNumber[0]) Integer.parseInt Integer strNumber[0] strNumber 0 int w = Integer.parseInt(strNumber[1]); w Integer.parseInt(strNumber[1]) Integer.parseInt Integer strNumber[1] strNumber 1 squareList.add(new Square(h,w)) squareList.add squareList new Square(h,w) for(Square square : squareList){
				outputSquare(square.h , square.w);
				System.out.println();
	        } Square square squareList {
				outputSquare(square.h , square.w);
				System.out.println();
	        } {
				outputSquare(square.h , square.w);
				System.out.println();
	        } outputSquare(square.h , square.w) outputSquare square.h square square.h square.w square square.w System.out.println() System.out.println System.out System System.out /**
	 * ????????¢?????????
	 * @param h
	 * @param w
	 */
	private void outputSquare(int h, int w) {
		StringBuilder sbLine = new StringBuilder();
		StringBuilder sbLineFastLast = new StringBuilder();
		for(int i=0;i < w ;i++){
			sbLineFastLast.append("#");
			if(i == 0 || i == w - 1){
				sbLine.append("#");
			}
			else
			{
				sbLine.append(".");
			}
		}
		for(int i=0;i < h;i++){
			if(i==0 || i == h-1){
				System.out.println(sbLineFastLast.toString());
			}else{
				System.out.println(sbLine.toString());
			}
		}
	} outputSquare {
		StringBuilder sbLine = new StringBuilder();
		StringBuilder sbLineFastLast = new StringBuilder();
		for(int i=0;i < w ;i++){
			sbLineFastLast.append("#");
			if(i == 0 || i == w - 1){
				sbLine.append("#");
			}
			else
			{
				sbLine.append(".");
			}
		}
		for(int i=0;i < h;i++){
			if(i==0 || i == h-1){
				System.out.println(sbLineFastLast.toString());
			}else{
				System.out.println(sbLine.toString());
			}
		}
	} StringBuilder sbLine = new StringBuilder(); sbLine new StringBuilder() StringBuilder sbLineFastLast = new StringBuilder(); sbLineFastLast new StringBuilder() for(int i=0;i < w ;i++){
			sbLineFastLast.append("#");
			if(i == 0 || i == w - 1){
				sbLine.append("#");
			}
			else
			{
				sbLine.append(".");
			}
		} int i=0; int i=0; i 0 i < w i w i++ i++ i {
			sbLineFastLast.append("#");
			if(i == 0 || i == w - 1){
				sbLine.append("#");
			}
			else
			{
				sbLine.append(".");
			}
		} {
			sbLineFastLast.append("#");
			if(i == 0 || i == w - 1){
				sbLine.append("#");
			}
			else
			{
				sbLine.append(".");
			}
		} sbLineFastLast.append("#") sbLineFastLast.append sbLineFastLast "#" if(i == 0 || i == w - 1){
				sbLine.append("#");
			}
			else
			{
				sbLine.append(".");
			} i == 0 || i == w - 1 i == 0 i 0 i == w - 1 i w - 1 w 1 {
				sbLine.append("#");
			} sbLine.append("#") sbLine.append sbLine "#" {
				sbLine.append(".");
			} sbLine.append(".") sbLine.append sbLine "." for(int i=0;i < h;i++){
			if(i==0 || i == h-1){
				System.out.println(sbLineFastLast.toString());
			}else{
				System.out.println(sbLine.toString());
			}
		} int i=0; int i=0; i 0 i < h i h i++ i++ i {
			if(i==0 || i == h-1){
				System.out.println(sbLineFastLast.toString());
			}else{
				System.out.println(sbLine.toString());
			}
		} {
			if(i==0 || i == h-1){
				System.out.println(sbLineFastLast.toString());
			}else{
				System.out.println(sbLine.toString());
			}
		} if(i==0 || i == h-1){
				System.out.println(sbLineFastLast.toString());
			}else{
				System.out.println(sbLine.toString());
			} i==0 || i == h-1 i==0 i 0 i == h-1 i h-1 h 1 {
				System.out.println(sbLineFastLast.toString());
			} System.out.println(sbLineFastLast.toString()) System.out.println System.out System System.out sbLineFastLast.toString() sbLineFastLast.toString sbLineFastLast {
				System.out.println(sbLine.toString());
			} System.out.println(sbLine.toString()) System.out.println System.out System System.out sbLine.toString() sbLine.toString sbLine int h h int w w class Square{

		public int h;
		public int w;

		Square(int _h ,int _w){
			h = _h;
			w = _w;
		}
	} Square public int h; h public int w; w Square(int _h ,int _w){
			h = _h;
			w = _w;
		} Square {
			h = _h;
			w = _w;
		} h = _h h _h w = _w w _w int _h _h int _w _w public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	public void run(){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String inputData;
        List<Square> squareList = new ArrayList<Square>();
        try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
	            if("0 0".equals(inputData)){
	            	break;
	            }else{
					String[] strNumber = inputData.split(" ");
					int h = Integer.parseInt(strNumber[0]);
					int w = Integer.parseInt(strNumber[1]);
					squareList.add(new Square(h,w));
	            }
	        }

	        //??????
	        for(Square square : squareList){
				outputSquare(square.h , square.w);
				System.out.println();
	        }

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	/**
	 * ????????¢?????????
	 * @param h
	 * @param w
	 */
	private void outputSquare(int h, int w) {
		StringBuilder sbLine = new StringBuilder();
		StringBuilder sbLineFastLast = new StringBuilder();
		for(int i=0;i < w ;i++){
			sbLineFastLast.append("#");
			if(i == 0 || i == w - 1){
				sbLine.append("#");
			}
			else
			{
				sbLine.append(".");
			}
		}
		for(int i=0;i < h;i++){
			if(i==0 || i == h-1){
				System.out.println(sbLineFastLast.toString());
			}else{
				System.out.println(sbLine.toString());
			}
		}
	}

	/**
	 * ????§???¢?????????
	 * h,w???????????????
	 * ??????Inner??????????????????????????§????????????????????§?????????
	 *   ?????????????????????????????§?????¬????????????????????????????????¨?????????
	 *   AOJ??????Main??????????????????submit???????????????
	 *   ?????????????????£????????§Inner?????????????????????????????????
	 */
	class Square{

		public int h;
		public int w;

		Square(int _h ,int _w){
			h = _h;
			w = _w;
		}
	}

} public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	public void run(){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String inputData;
        List<Square> squareList = new ArrayList<Square>();
        try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
	            if("0 0".equals(inputData)){
	            	break;
	            }else{
					String[] strNumber = inputData.split(" ");
					int h = Integer.parseInt(strNumber[0]);
					int w = Integer.parseInt(strNumber[1]);
					squareList.add(new Square(h,w));
	            }
	        }

	        //??????
	        for(Square square : squareList){
				outputSquare(square.h , square.w);
				System.out.println();
	        }

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	/**
	 * ????????¢?????????
	 * @param h
	 * @param w
	 */
	private void outputSquare(int h, int w) {
		StringBuilder sbLine = new StringBuilder();
		StringBuilder sbLineFastLast = new StringBuilder();
		for(int i=0;i < w ;i++){
			sbLineFastLast.append("#");
			if(i == 0 || i == w - 1){
				sbLine.append("#");
			}
			else
			{
				sbLine.append(".");
			}
		}
		for(int i=0;i < h;i++){
			if(i==0 || i == h-1){
				System.out.println(sbLineFastLast.toString());
			}else{
				System.out.println(sbLine.toString());
			}
		}
	}

	/**
	 * ????§???¢?????????
	 * h,w???????????????
	 * ??????Inner??????????????????????????§????????????????????§?????????
	 *   ?????????????????????????????§?????¬????????????????????????????????¨?????????
	 *   AOJ??????Main??????????????????submit???????????????
	 *   ?????????????????£????????§Inner?????????????????????????????????
	 */
	class Square{

		public int h;
		public int w;

		Square(int _h ,int _w){
			h = _h;
			w = _w;
		}
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 * ??\????????????????????????H cm ?????? W cm ???????????????????????°?????????????????????????????????

##########
#........#
#........#
#........#
#........#
##########
?????????????????? 6 cm ?????? 10 cm ???????????¨??????????????????

 * @author wsKmatsuda
 *
 */
public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	public void run(){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String inputData;
        List<Square> squareList = new ArrayList<Square>();
        try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
	            if("0 0".equals(inputData)){
	            	break;
	            }else{
					String[] strNumber = inputData.split(" ");
					int h = Integer.parseInt(strNumber[0]);
					int w = Integer.parseInt(strNumber[1]);
					squareList.add(new Square(h,w));
	            }
	        }

	        //??????
	        for(Square square : squareList){
				outputSquare(square.h , square.w);
				System.out.println();
	        }

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	/**
	 * ????????¢?????????
	 * @param h
	 * @param w
	 */
	private void outputSquare(int h, int w) {
		StringBuilder sbLine = new StringBuilder();
		StringBuilder sbLineFastLast = new StringBuilder();
		for(int i=0;i < w ;i++){
			sbLineFastLast.append("#");
			if(i == 0 || i == w - 1){
				sbLine.append("#");
			}
			else
			{
				sbLine.append(".");
			}
		}
		for(int i=0;i < h;i++){
			if(i==0 || i == h-1){
				System.out.println(sbLineFastLast.toString());
			}else{
				System.out.println(sbLine.toString());
			}
		}
	}

	/**
	 * ????§???¢?????????
	 * h,w???????????????
	 * ??????Inner??????????????????????????§????????????????????§?????????
	 *   ?????????????????????????????§?????¬????????????????????????????????¨?????????
	 *   AOJ??????Main??????????????????submit???????????????
	 *   ?????????????????£????????§Inner?????????????????????????????????
	 */
	class Square{

		public int h;
		public int w;

		Square(int _h ,int _w){
			h = _h;
			w = _w;
		}
	}

}