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

  val info = (1 to n).map { _ =>
    val b = scanner.nextInt()
    val f = scanner.nextInt()
    val r = scanner.nextInt()
    val v = scanner.nextInt()

    (b-1, f-1, r-1, v)
  }

  val init = Array.fill(4, 3, 10)(0)

  val outputs = info.foldLeft(init) {
    case (acc, (b, f, r, v)) =>
      acc(b)(f)(r) = v
      acc
  }

  val output = outputs.map { office =>
    office.map { floor => 
      " " + floor.mkString(" ")
    }.mkString("\n")
  }.mkString("\n" + "#" * 20 + "\n")

  println(output)
}