import Control.Monad
import Data.List

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

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