object Main {
  def main(args: Array[String]) {
    val SEP = "####################"

    val input = scala.io.Source.stdin.getLines().toList.tail.map(_.split(' ').map(_.toInt))

    val houseMap = List.tabulate(4, 3, 10) { (b, f, r) =>
      input.collect { case Array(x, y, z, v) if x - 1 == b && y - 1 == f && z - 1 == r => v }.sum
    }

    println(houseMap.map(_.map(_.map(" " + _).mkString).mkString("\n")).mkString("\n" + SEP + "\n"))
  }
}