object Main {
  def main(args:Array[String]):Unit = {
    for (line <- scala.io.Source.stdin.getLines() if line != "0 0") {
      val Array(h, w) = line.split(" ").map(_.toInt)
      println("#" * w)
      for (i <- 1 to h-2) {
        println("#" + "." * (w-2) + "#")
      }
      println("#" * w + "\n")
    }
  }
}