import Control.Monad
import Data.List
import GHC.Exts

main = do
  [n,l,t] <- map read . words <$> getLine
  xws <- map (map read . words) <$> replicateM n getLine :: IO [[Int]]
  mapM_ print $ solve n l t xws

solve n l t ([x1,w1]:xws)
  | d >= 0 = d:drop (n-d) ps ++ take (n-d) ps
  | d < 0 = drop (-d)  ps ++ take (-d)  ps
  where
  d = sum (map cross xws) `mod` n
  cross [x2,w2]
    | w1 == w2  = 0
    | w1 == 1   =   div ( l + 2 * ( t - m + x1 ) ) l
    | w1 == 2   = - div ( l + 2 * ( t - m + x2 ) ) l
    where m = (x1+x2+1) `div` 2
  moved x w = ( x + t * (3-w*2) ) `mod` l
  ps = sortWith (\p -> ( l + p - moved x1 w1 )`mod`l) [ moved x w | [x,w] <- [x1,w1]:xws ]
