object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    def printFrame(w: Int, h: Int): Unit = {
      if (w == 0 && h == 0) {
        println("#" * w)

        for (i <- 2 to h - 1) {
          println("#" + "." * (w - 2) + "#")

        }
        println("#" * w)
        println
        printFrame(sc.nextInt, sc.nextInt)
      }
    }

    printFrame(sc.nextInt, sc.nextInt)

  }
}