import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created 2017/06/04.
 */
public class Main {
  public static void main(String[] args) {

    //??\?????¨?????????
    Scanner sc = new Scanner(System.in);
    ArrayList<ArrayList<Integer>> ary_input = new ArrayList<>();
    while (true) {
      ArrayList<Integer> ary = new ArrayList<>();
      int input1 = Integer.parseInt(sc.next());
      int input2 = Integer.parseInt(sc.next());
      if (input1 == 0 && input2 == 0) break;
      ary.add(input1);
      ary.add(input2);
      ary_input.add(ary);
    }
    //System.out.println(ary_input);

    //??????????????????????´?????????????????????????
    ArrayList<ArrayList<StringBuilder>> ary_sb = new ArrayList<>();

    for (ArrayList<Integer> index : ary_input) {
      ary_sb.add(sisaku(index.get(0), index.get(1)));
    }
    //System.out.println(ary_sb);
    
    //??¨?????¢???????????????
    for (int i = 0; i < ary_sb.size(); i++) {
      for (int j = 0; j < ary_sb.get(i).size(); j++) {
        System.out.println(ary_sb.get(i).get(j));
      }
        System.out.println("");
    }
  }

  public static ArrayList<StringBuilder> sisaku(int a, int b) {
    ArrayList<StringBuilder> ary = new ArrayList<>();
    for (int i = 0; i < a; i++) {
      StringBuilder str1 = new StringBuilder("");
      for (int j = 0; j < b; j++) {
        if (i == 0 || i == (a - 1)) {
          str1 = str1.append("#");
        } else {
          if (j == 0 || j == (b - 1)) {
            str1 = str1.append("#");
          } else {
            str1 = str1.append(".");
          }
        }
      }
      ary.add(str1);
    }
    return ary;
  }
} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {

    //??\?????¨?????????
    Scanner sc = new Scanner(System.in);
    ArrayList<ArrayList<Integer>> ary_input = new ArrayList<>();
    while (true) {
      ArrayList<Integer> ary = new ArrayList<>();
      int input1 = Integer.parseInt(sc.next());
      int input2 = Integer.parseInt(sc.next());
      if (input1 == 0 && input2 == 0) break;
      ary.add(input1);
      ary.add(input2);
      ary_input.add(ary);
    }
    //System.out.println(ary_input);

    //??????????????????????´?????????????????????????
    ArrayList<ArrayList<StringBuilder>> ary_sb = new ArrayList<>();

    for (ArrayList<Integer> index : ary_input) {
      ary_sb.add(sisaku(index.get(0), index.get(1)));
    }
    //System.out.println(ary_sb);
    
    //??¨?????¢???????????????
    for (int i = 0; i < ary_sb.size(); i++) {
      for (int j = 0; j < ary_sb.get(i).size(); j++) {
        System.out.println(ary_sb.get(i).get(j));
      }
        System.out.println("");
    }
  }

  public static ArrayList<StringBuilder> sisaku(int a, int b) {
    ArrayList<StringBuilder> ary = new ArrayList<>();
    for (int i = 0; i < a; i++) {
      StringBuilder str1 = new StringBuilder("");
      for (int j = 0; j < b; j++) {
        if (i == 0 || i == (a - 1)) {
          str1 = str1.append("#");
        } else {
          if (j == 0 || j == (b - 1)) {
            str1 = str1.append("#");
          } else {
            str1 = str1.append(".");
          }
        }
      }
      ary.add(str1);
    }
    return ary;
  }
} Main public static void main(String[] args) {

    //??\?????¨?????????
    Scanner sc = new Scanner(System.in);
    ArrayList<ArrayList<Integer>> ary_input = new ArrayList<>();
    while (true) {
      ArrayList<Integer> ary = new ArrayList<>();
      int input1 = Integer.parseInt(sc.next());
      int input2 = Integer.parseInt(sc.next());
      if (input1 == 0 && input2 == 0) break;
      ary.add(input1);
      ary.add(input2);
      ary_input.add(ary);
    }
    //System.out.println(ary_input);

    //??????????????????????´?????????????????????????
    ArrayList<ArrayList<StringBuilder>> ary_sb = new ArrayList<>();

    for (ArrayList<Integer> index : ary_input) {
      ary_sb.add(sisaku(index.get(0), index.get(1)));
    }
    //System.out.println(ary_sb);
    
    //??¨?????¢???????????????
    for (int i = 0; i < ary_sb.size(); i++) {
      for (int j = 0; j < ary_sb.get(i).size(); j++) {
        System.out.println(ary_sb.get(i).get(j));
      }
        System.out.println("");
    }
  } main {

    //??\?????¨?????????
    Scanner sc = new Scanner(System.in);
    ArrayList<ArrayList<Integer>> ary_input = new ArrayList<>();
    while (true) {
      ArrayList<Integer> ary = new ArrayList<>();
      int input1 = Integer.parseInt(sc.next());
      int input2 = Integer.parseInt(sc.next());
      if (input1 == 0 && input2 == 0) break;
      ary.add(input1);
      ary.add(input2);
      ary_input.add(ary);
    }
    //System.out.println(ary_input);

    //??????????????????????´?????????????????????????
    ArrayList<ArrayList<StringBuilder>> ary_sb = new ArrayList<>();

    for (ArrayList<Integer> index : ary_input) {
      ary_sb.add(sisaku(index.get(0), index.get(1)));
    }
    //System.out.println(ary_sb);
    
    //??¨?????¢???????????????
    for (int i = 0; i < ary_sb.size(); i++) {
      for (int j = 0; j < ary_sb.get(i).size(); j++) {
        System.out.println(ary_sb.get(i).get(j));
      }
        System.out.println("");
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) ArrayList<ArrayList<Integer>> ary_input = new ArrayList<>(); ary_input new ArrayList<>() while (true) {
      ArrayList<Integer> ary = new ArrayList<>();
      int input1 = Integer.parseInt(sc.next());
      int input2 = Integer.parseInt(sc.next());
      if (input1 == 0 && input2 == 0) break;
      ary.add(input1);
      ary.add(input2);
      ary_input.add(ary);
    } true {
      ArrayList<Integer> ary = new ArrayList<>();
      int input1 = Integer.parseInt(sc.next());
      int input2 = Integer.parseInt(sc.next());
      if (input1 == 0 && input2 == 0) break;
      ary.add(input1);
      ary.add(input2);
      ary_input.add(ary);
    } ArrayList<Integer> ary = new ArrayList<>(); ary new ArrayList<>() int input1 = Integer.parseInt(sc.next()); input1 Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int input2 = Integer.parseInt(sc.next()); input2 Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc if (input1 == 0 && input2 == 0) break; input1 == 0 && input2 == 0 input1 == 0 input1 0 input2 == 0 input2 0 break; ary.add(input1) ary.add ary input1 ary.add(input2) ary.add ary input2 ary_input.add(ary) ary_input.add ary_input ary ArrayList<ArrayList<StringBuilder>> ary_sb = new ArrayList<>(); ary_sb new ArrayList<>() for (ArrayList<Integer> index : ary_input) {
      ary_sb.add(sisaku(index.get(0), index.get(1)));
    } ArrayList<Integer> index ary_input {
      ary_sb.add(sisaku(index.get(0), index.get(1)));
    } {
      ary_sb.add(sisaku(index.get(0), index.get(1)));
    } ary_sb.add(sisaku(index.get(0), index.get(1))) ary_sb.add ary_sb sisaku(index.get(0), index.get(1)) sisaku index.get(0) index.get index 0 index.get(1) index.get index 1 for (int i = 0; i < ary_sb.size(); i++) {
      for (int j = 0; j < ary_sb.get(i).size(); j++) {
        System.out.println(ary_sb.get(i).get(j));
      }
        System.out.println("");
    } int i = 0; int i = 0; i 0 i < ary_sb.size() i ary_sb.size() ary_sb.size ary_sb i++ i++ i {
      for (int j = 0; j < ary_sb.get(i).size(); j++) {
        System.out.println(ary_sb.get(i).get(j));
      }
        System.out.println("");
    } {
      for (int j = 0; j < ary_sb.get(i).size(); j++) {
        System.out.println(ary_sb.get(i).get(j));
      }
        System.out.println("");
    } for (int j = 0; j < ary_sb.get(i).size(); j++) {
        System.out.println(ary_sb.get(i).get(j));
      } int j = 0; int j = 0; j 0 j < ary_sb.get(i).size() j ary_sb.get(i).size() ary_sb.get(i).size ary_sb.get(i) ary_sb.get ary_sb i j++ j++ j {
        System.out.println(ary_sb.get(i).get(j));
      } {
        System.out.println(ary_sb.get(i).get(j));
      } System.out.println(ary_sb.get(i).get(j)) System.out.println System.out System System.out ary_sb.get(i).get(j) ary_sb.get(i).get ary_sb.get(i) ary_sb.get ary_sb i j System.out.println("") System.out.println System.out System System.out "" String[] args args public static ArrayList<StringBuilder> sisaku(int a, int b) {
    ArrayList<StringBuilder> ary = new ArrayList<>();
    for (int i = 0; i < a; i++) {
      StringBuilder str1 = new StringBuilder("");
      for (int j = 0; j < b; j++) {
        if (i == 0 || i == (a - 1)) {
          str1 = str1.append("#");
        } else {
          if (j == 0 || j == (b - 1)) {
            str1 = str1.append("#");
          } else {
            str1 = str1.append(".");
          }
        }
      }
      ary.add(str1);
    }
    return ary;
  } sisaku {
    ArrayList<StringBuilder> ary = new ArrayList<>();
    for (int i = 0; i < a; i++) {
      StringBuilder str1 = new StringBuilder("");
      for (int j = 0; j < b; j++) {
        if (i == 0 || i == (a - 1)) {
          str1 = str1.append("#");
        } else {
          if (j == 0 || j == (b - 1)) {
            str1 = str1.append("#");
          } else {
            str1 = str1.append(".");
          }
        }
      }
      ary.add(str1);
    }
    return ary;
  } ArrayList<StringBuilder> ary = new ArrayList<>(); ary new ArrayList<>() for (int i = 0; i < a; i++) {
      StringBuilder str1 = new StringBuilder("");
      for (int j = 0; j < b; j++) {
        if (i == 0 || i == (a - 1)) {
          str1 = str1.append("#");
        } else {
          if (j == 0 || j == (b - 1)) {
            str1 = str1.append("#");
          } else {
            str1 = str1.append(".");
          }
        }
      }
      ary.add(str1);
    } int i = 0; int i = 0; i 0 i < a i a i++ i++ i {
      StringBuilder str1 = new StringBuilder("");
      for (int j = 0; j < b; j++) {
        if (i == 0 || i == (a - 1)) {
          str1 = str1.append("#");
        } else {
          if (j == 0 || j == (b - 1)) {
            str1 = str1.append("#");
          } else {
            str1 = str1.append(".");
          }
        }
      }
      ary.add(str1);
    } {
      StringBuilder str1 = new StringBuilder("");
      for (int j = 0; j < b; j++) {
        if (i == 0 || i == (a - 1)) {
          str1 = str1.append("#");
        } else {
          if (j == 0 || j == (b - 1)) {
            str1 = str1.append("#");
          } else {
            str1 = str1.append(".");
          }
        }
      }
      ary.add(str1);
    } StringBuilder str1 = new StringBuilder(""); str1 new StringBuilder("") for (int j = 0; j < b; j++) {
        if (i == 0 || i == (a - 1)) {
          str1 = str1.append("#");
        } else {
          if (j == 0 || j == (b - 1)) {
            str1 = str1.append("#");
          } else {
            str1 = str1.append(".");
          }
        }
      } int j = 0; int j = 0; j 0 j < b j b j++ j++ j {
        if (i == 0 || i == (a - 1)) {
          str1 = str1.append("#");
        } else {
          if (j == 0 || j == (b - 1)) {
            str1 = str1.append("#");
          } else {
            str1 = str1.append(".");
          }
        }
      } {
        if (i == 0 || i == (a - 1)) {
          str1 = str1.append("#");
        } else {
          if (j == 0 || j == (b - 1)) {
            str1 = str1.append("#");
          } else {
            str1 = str1.append(".");
          }
        }
      } if (i == 0 || i == (a - 1)) {
          str1 = str1.append("#");
        } else {
          if (j == 0 || j == (b - 1)) {
            str1 = str1.append("#");
          } else {
            str1 = str1.append(".");
          }
        } i == 0 || i == (a - 1) i == 0 i 0 i == (a - 1) i (a - 1) a 1 {
          str1 = str1.append("#");
        } str1 = str1.append("#") str1 str1.append("#") str1.append str1 "#" {
          if (j == 0 || j == (b - 1)) {
            str1 = str1.append("#");
          } else {
            str1 = str1.append(".");
          }
        } if (j == 0 || j == (b - 1)) {
            str1 = str1.append("#");
          } else {
            str1 = str1.append(".");
          } j == 0 || j == (b - 1) j == 0 j 0 j == (b - 1) j (b - 1) b 1 {
            str1 = str1.append("#");
          } str1 = str1.append("#") str1 str1.append("#") str1.append str1 "#" {
            str1 = str1.append(".");
          } str1 = str1.append(".") str1 str1.append(".") str1.append str1 "." ary.add(str1) ary.add ary str1 return ary; ary int a a int b b public class Main {
  public static void main(String[] args) {

    //??\?????¨?????????
    Scanner sc = new Scanner(System.in);
    ArrayList<ArrayList<Integer>> ary_input = new ArrayList<>();
    while (true) {
      ArrayList<Integer> ary = new ArrayList<>();
      int input1 = Integer.parseInt(sc.next());
      int input2 = Integer.parseInt(sc.next());
      if (input1 == 0 && input2 == 0) break;
      ary.add(input1);
      ary.add(input2);
      ary_input.add(ary);
    }
    //System.out.println(ary_input);

    //??????????????????????´?????????????????????????
    ArrayList<ArrayList<StringBuilder>> ary_sb = new ArrayList<>();

    for (ArrayList<Integer> index : ary_input) {
      ary_sb.add(sisaku(index.get(0), index.get(1)));
    }
    //System.out.println(ary_sb);
    
    //??¨?????¢???????????????
    for (int i = 0; i < ary_sb.size(); i++) {
      for (int j = 0; j < ary_sb.get(i).size(); j++) {
        System.out.println(ary_sb.get(i).get(j));
      }
        System.out.println("");
    }
  }

  public static ArrayList<StringBuilder> sisaku(int a, int b) {
    ArrayList<StringBuilder> ary = new ArrayList<>();
    for (int i = 0; i < a; i++) {
      StringBuilder str1 = new StringBuilder("");
      for (int j = 0; j < b; j++) {
        if (i == 0 || i == (a - 1)) {
          str1 = str1.append("#");
        } else {
          if (j == 0 || j == (b - 1)) {
            str1 = str1.append("#");
          } else {
            str1 = str1.append(".");
          }
        }
      }
      ary.add(str1);
    }
    return ary;
  }
} public class Main {
  public static void main(String[] args) {

    //??\?????¨?????????
    Scanner sc = new Scanner(System.in);
    ArrayList<ArrayList<Integer>> ary_input = new ArrayList<>();
    while (true) {
      ArrayList<Integer> ary = new ArrayList<>();
      int input1 = Integer.parseInt(sc.next());
      int input2 = Integer.parseInt(sc.next());
      if (input1 == 0 && input2 == 0) break;
      ary.add(input1);
      ary.add(input2);
      ary_input.add(ary);
    }
    //System.out.println(ary_input);

    //??????????????????????´?????????????????????????
    ArrayList<ArrayList<StringBuilder>> ary_sb = new ArrayList<>();

    for (ArrayList<Integer> index : ary_input) {
      ary_sb.add(sisaku(index.get(0), index.get(1)));
    }
    //System.out.println(ary_sb);
    
    //??¨?????¢???????????????
    for (int i = 0; i < ary_sb.size(); i++) {
      for (int j = 0; j < ary_sb.get(i).size(); j++) {
        System.out.println(ary_sb.get(i).get(j));
      }
        System.out.println("");
    }
  }

  public static ArrayList<StringBuilder> sisaku(int a, int b) {
    ArrayList<StringBuilder> ary = new ArrayList<>();
    for (int i = 0; i < a; i++) {
      StringBuilder str1 = new StringBuilder("");
      for (int j = 0; j < b; j++) {
        if (i == 0 || i == (a - 1)) {
          str1 = str1.append("#");
        } else {
          if (j == 0 || j == (b - 1)) {
            str1 = str1.append("#");
          } else {
            str1 = str1.append(".");
          }
        }
      }
      ary.add(str1);
    }
    return ary;
  }
} Main
import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created 2017/06/04.
 */
public class Main {
  public static void main(String[] args) {

    //??\?????¨?????????
    Scanner sc = new Scanner(System.in);
    ArrayList<ArrayList<Integer>> ary_input = new ArrayList<>();
    while (true) {
      ArrayList<Integer> ary = new ArrayList<>();
      int input1 = Integer.parseInt(sc.next());
      int input2 = Integer.parseInt(sc.next());
      if (input1 == 0 && input2 == 0) break;
      ary.add(input1);
      ary.add(input2);
      ary_input.add(ary);
    }
    //System.out.println(ary_input);

    //??????????????????????´?????????????????????????
    ArrayList<ArrayList<StringBuilder>> ary_sb = new ArrayList<>();

    for (ArrayList<Integer> index : ary_input) {
      ary_sb.add(sisaku(index.get(0), index.get(1)));
    }
    //System.out.println(ary_sb);
    
    //??¨?????¢???????????????
    for (int i = 0; i < ary_sb.size(); i++) {
      for (int j = 0; j < ary_sb.get(i).size(); j++) {
        System.out.println(ary_sb.get(i).get(j));
      }
        System.out.println("");
    }
  }

  public static ArrayList<StringBuilder> sisaku(int a, int b) {
    ArrayList<StringBuilder> ary = new ArrayList<>();
    for (int i = 0; i < a; i++) {
      StringBuilder str1 = new StringBuilder("");
      for (int j = 0; j < b; j++) {
        if (i == 0 || i == (a - 1)) {
          str1 = str1.append("#");
        } else {
          if (j == 0 || j == (b - 1)) {
            str1 = str1.append("#");
          } else {
            str1 = str1.append(".");
          }
        }
      }
      ary.add(str1);
    }
    return ary;
  }
}