object Main extends App {
  def buildFrame(x: (Int, Int)): String = {
    (List("#" * x._2) ::: List.fill(x._1 - 2)(s"#${"." * (x._2 - 2)}#") ::: List("#" * x._2)).mkString("\n")
  }

  scala.io.Source.stdin.getLines.toList.init
    .map(_.split(" ").map(_.toInt))
    .map(x => (x(0), x(1)))
    .map(buildFrame)
    .map(x => println(x + "\n"))
}