object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val in = List.fill(n, 4)(sc.nextInt())
  val buildings: List[Building] = (1 to 4).map(n => createEmptyBuilding(n, 3, 10)).toList

  for (data <- in) {
    updateTenant(buildings, data)
  }

  printAns(buildings)

  def createEmptyBuilding(buildNo: Int, level: Int, room: Int): Building = {
    val floorList: List[Floor] = (1 to level).map(l => Floor(l, scala.collection.mutable.Seq.fill(room)(0))).toList
    Building(buildNo, floorList)
  }

  def updateTenant(bldgs: List[Building], d: List[Int]): Unit = {
    val target = bldgs(d(0) - 1).floorList(d(1) - 1).tenant(d(2) - 1)
    target match {
      case 0 => bldgs(d(0) - 1).floorList(d(1) - 1).tenant.update(d(2) - 1, d(3))
      case _ => bldgs(d(0) - 1).floorList(d(1) - 1).tenant.update(d(2) - 1, target + d(3))
    }
  }

  def printAns(bldgs: List[Building]): Unit = {
    for (b <- bldgs) {
      b.buildNo match {
        case 4 => b.floorList.foreach(f => println(f.tenant.mkString(" ")))
        case _ =>
          b.floorList.foreach(f => println(f.tenant.mkString(" ")))
          println("####################")
      }
    }
  }

  case class Building(buildNo: Int, floorList: List[Floor])

  case class Floor(level: Int, tenant: scala.collection.mutable.Seq[Int])

}