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;
		}
	}

}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz