type Room      = Int
type Floor     = [Room]
type Building  = [Floor]
type Buildings = [Building]

setupBuildings :: Buildings
setupBuildings = replicate 4 $ replicate 3 $ replicate 10 0

getBuilding :: Int -> Buildings -> Building
getBuilding b blds = blds !! (b - 1)

getFloor :: Int -> Int -> Buildings -> Floor
getFloor b f blds = getBuilding b blds !! (f - 1)

getRoom :: Int -> Int -> Int -> Buildings -> Room
getRoom b f r blds = getFloor b f blds !! (r - 1)

addMember :: Int -> Int -> Floor -> Floor
addMember 1 v (x:xs) = (x + v):xs
addMember r v (x:xs) = x:(addMember (r - 1) v xs)

updateMemberAtFloor :: Int -> Int -> Int -> Building -> Building
updateMemberAtFloor 1 r v (x:xs) = (addMember r v x):xs
updateMemberAtFloor f r v (x:xs) = x:(updateMemberAtFloor (f - 1) r v xs)

updateMember :: Int -> Int -> Int -> Int -> Buildings -> Buildings
updateMember 1 f r v (x:xs) = (updateMemberAtFloor f r v x):xs
updateMember b f r v (x:xs) = x:(updateMember (b - 1) f r v xs)

printFloor :: Floor -> IO ()
printFloor []     = putStrLn ""
printFloor (x:xs) = (putStr $ " " ++ show x) >> printFloor xs

printBuilding :: Building -> IO ()
printBuilding []     = return()
printBuilding (x:xs) = printFloor x >> printBuilding xs

printBuildings :: Buildings -> IO ()
printBuildings (x:[]) = printBuilding x
printBuildings (x:xs) = printBuilding x >> (putStrLn $ replicate 20 '#') >> printBuildings xs

readRoomData :: Int -> Buildings -> IO Buildings
readRoomData 0 blds = return blds
readRoomData n blds = do
    [b, f, r, v] <- getLine >>= return.(map (\n -> read n :: Int)).words
    readRoomData (n - 1) $ updateMember b f r v blds

main :: IO ()
main = do
    n <- getLine >>= return.read :: IO Int
    readRoomData n setupBuildings >>= printBuildings

