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 n l t xws

solve n l t xws = drop d ps' ++ take d ps'
  where
  d = sum ds `mod` n
  moved x w = x + t * (3-w*2)
  ps' = sort ps
  (ds,ps) = unzip [ moved x w `divMod` l | [x,w] <- xws ]
