object Main extends App {
  val scanner = new java.util.Scanner(System.in)

  val data = Iterator.continually {
    val H  = scanner.nextInt()
    val W  = scanner.nextInt()

    (H, W)
  }

  val outputs = data.takeWhile(_ != (0, 0)).map {
    case (h, w) =>
      s"${"#" * w}\n" +
        s"#${"." * (w-2)}#\n" * (h-2) +
        s"${"#" * w}\n"
  }

  outputs.foreach(println)
}