loop = gets.to_i

info = Hash.new{|h,k| h[k]=Hash.new(&h.default_proc)}
loop.times{
    b, f, r, v = gets.chomp.split
    if info[b][f][r].empty?
        info[b][f][r] = v.to_i
    elsif info[b][f][r] + v.to_i > 9
        info[b][f][r] += 9
    elsif info[b][f][r] + v.to_i < 0
        info[b][f][r] = 0
    end
}

for b in 1..4
    for f in 1..3
        for r in 1..10
            tou = b.to_s
            kai = f.to_s
            room = r.to_s
            if info[tou][kai][room] == {}
                print " 0"
            else
                print " #{info[tou][kai][room]}"
            end
            if r == 10
                puts ""
            end
        end
    end
    print "####################\n" if b != 4
end
