object Main extends App {
  val ans = scala.io.Source.stdin.getLines.toList.tail
    .map(_.split(" ").map(_.toInt - 1))
    .foldLeft(Array.fill(4, 3, 10)(0)){ case (state, Array(b, f, r, v)) =>
      state(b)(f)(r) += v + 1
      state
    }
    .map(_.map(_.map(" " + _).mkString("")).mkString("\n"))
    .mkString("\n" + ("#" * 20) + "\n")
  println(ans)
}