val SEPARATOR = "####################"
val FLOORS = 1..3
val ROOMS  = 1..10
val DORMITORIES = 1..4

fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val allRooms = hashMapOf<String, Int>().withDefault { 0 }
    (1..n).forEach {
        val (b, f, r, v) = readLine()?.split(" ") ?: return
        val key = "$b $f $r"
        val counts = allRooms.getValue(key)
        allRooms.put(key, counts + v.toInt() )
    }
    val builder = StringBuilder()
    DORMITORIES.forEach { dormitoryNum ->
        FLOORS.forEach{ floorNum ->
            ROOMS.forEach{ roomNum ->
                val count = allRooms.getValue("$dormitoryNum $floorNum $roomNum")
                builder.append(" $count")
            }
            println(builder.toString())
            builder.setLength(0)
        }
        if (dormitoryNum != DORMITORIES.last) println(SEPARATOR)
    }
}
