main = do
    fs <- getLine
    ss <- getContents
    let ls = lines ss
    let initBlds = replicate 4 initBld
    let finBlds = visitBlds initBlds ls
    printBlds finBlds

printBlds [] = return ()
printBlds [x] = printBld x
printBlds (x:xs) = do
    printBld x
    putStrLn "####################"
    printBlds xs

printBld bld = mapM_ putStrLn $ showBld bld

visitBlds :: [Bld] -> [String] -> [Bld]
visitBlds blds [] = blds
visitBlds blds (x:xs) = visitBlds (visitBldLine blds x) xs

visitBldLine :: [Bld] -> String -> [Bld]
visitBldLine blds line = visitBld blds b f r v
  where
    ns = map (\x -> read x :: Int) $ words line
    b = ns!!0
    f = ns!!1
    r = ns!!2
    v = ns!!3

visitBld :: [Bld] -> Int -> Int -> Int -> Int -> [Bld]
visitBld blds b f r v = map (\(bldNo, bld) -> if bldNo == b then visitFloor bld f r v else bld) $ zip [1..] blds
  where
    visitFloor floors f r v = map (\(lv, floor) -> if lv == f then visitRoom floor r v else floor) $ zip [1..] floors
    visitRoom rooms r v = map (\(roomNo, room) -> if roomNo == r then room+v else room) $ zip [1..] rooms


type Bld = [[Int]]

initBld :: Bld
initBld = replicate 3 $ replicate 10 0

showBld :: Bld -> [String]
showBld = map concat . map (map (\n -> ' ':show n))

