#!/usr/bin/env ruby

number = gets.chomp.to_i
office = Array.new(120,0)

number.times do |index|
    temp = gets.split.map(&:to_i)
    office[(temp[0] - 1)  * 30 + (temp[1] - 1) * 10 + (temp[2] - 1) ] += temp[3]
end

4.times do |tou|
    3.times do |floor|
        10.times do |no|
            print " #{office[tou * 30 + floor * 10 + no]}"
        end
        puts ""
    end
    unless tou == 3
        puts "#" * 20
    end
end
