
import scala.util.control.Breaks
object Main extends App {
  val b = new Breaks()
  b.breakable {
    while (true) {
      val Seq(h, w) = readLine().split(' ').map(_.toInt).toList

      if ((h, w) == (0, 0)) b.break

      println("#" * w)
      print(("#" + ("." * (w - 2)) + "#\n") * (h - 2))
      println("#" * w)
      println()
    }
  }
}
