
class Building
    attr_accessor :residents
    def initialize(residents:)
        self.residents = residents 
    end

    def move(floor,room_num,num)
        self.residents[floor-1][room_num-1] += num
        if self.residents[floor-1][room_num-1].negative? 
            self.residents[floor-1][room_num-1] = 0
        end
    end

    def info
        return "#{self.residents}"
    end

    def floor_info
        self.residents.each do |floor|
            for i in 0..floor.length-1 do
                print(" #{floor[i]}")
            end
            puts ""
        end
    end
end

def border
    puts "#" * 20
end

# 初期設定
building1 = Building.new(residents: Array.new(3).map{Array.new(10,0)})
building2 = Building.new(residents: Array.new(3).map{Array.new(10,0)})
building3 = Building.new(residents: Array.new(3).map{Array.new(10,0)})
building4 = Building.new(residents: Array.new(3).map{Array.new(10,0)})

buildings = [building1,building2,building3,building4]

n = gets.chomp.to_i
for i in 1..n do
    b,f,r,v = gets.chomp.split.map(&:to_i)
    buildings[b-1].move(f,r,v)
end
index = 0
buildings.each do |building|
    building.floor_info
    if index < 3
        border
    end
    index += 1
end

