output_description: Print N lines. The i-th line should contain the coordinate of ant i after T
  seconds. Here, each coordinate must be between 0 and L-1, inclusive.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N L T
      X_1 W_1
      X_2 W_2
      :
      X_N W_N
attempt: N, L, T = [int(item) for item in input().split()]
  pos_list = [[int(item) for item in input().split()] for _ in range(N)]
  
  first_ant = pos_list[0]
  # N 匹の蟻がいて、それぞれの蟻は 1 から N まで番号の書かれたゼッケンをつけている。
  # 二つの蟻が同じ場所についた瞬間、その二つの蟻はゼッケンを交換し、そのまますれ違って同じ方向に歩き続ける。
  # 上記問題の言い換えに生息するfirst ant さんの操作後の位置とゼッケンを求める
  if first_ant[1] == 1:  # 一番の子が1向きの場合
  
      last_pos_of_first_ant = (first_ant[0] + T) % L
      num_of_reverse_ant = [item[1] for item in pos_list].count(2)
  
      cnt = 0
      reverse_ant_pos = [item[0] for item in pos_list if item[1] == 2]
      cnt += T // L * len(reverse_ant_pos)
  
      for i in reverse_ant_pos:
          if (i - first_ant[0]) // 2 + 1 <= (T % L):
              cnt += 1
  
      last_num_of_first_ant = (1 + cnt) % N
      if last_num_of_first_ant == 0:
          last_num_of_first_ant += N
  
  else:
      last_pos_of_first_ant = (first_ant[0] - T) % L
      num_of_reverse_ant = [item[1] for item in pos_list].count(1)
  
      cnt = 0
      reverse_ant_pos = [item[0] for item in pos_list if item[1] == 1]
  
      cnt += T // L * len(reverse_ant_pos)
  
      for i in reverse_ant_pos:
          if ((first_ant[0] - (i - L)) // 2 + 1) <= (T % L):
              cnt += 1
              print(T % L)
              print(i, first_ant[0] - (i - L), (first_ant[0] - (i - L)) // 2 + 1)
              print("cnt", cnt)
  
      last_num_of_first_ant = (1 - cnt) % N
      if last_num_of_first_ant <= 0:
          last_num_of_first_ant += N
  
  # アリの位置を求める
  last_ant_pos = []
  
  for ant_pos, direction in pos_list:
      if direction == 1:
          last_ant_pos.append((ant_pos + T) % L)
      else:
          ant_pos = (ant_pos - T) % L
          if ant_pos < 0:
              ant_pos += L
          last_ant_pos.append(ant_pos)
  
  # first ant さんは位置Xにいるので、アリの位置リストからどれがfirst antさんか特定する。
  # 特定したらその位置にゼッケンを設定する。
  # 1方向のfirst antさんは、その他のゼッケンは時計回りに+1する（他のアリを1減らしながら回っているから）
  # 2方向のfirst antさんは、その他のゼッケンを時計回りに-1する（他のアリを1増やしながら回っているから。逆回りに・・・で考えたほうが分かりよいか？）
  # 2方向の場合はできたリストを逆順に出力する
  res = []
  if first_ant[1] == 1:
      for i, pos in enumerate(last_ant_pos):
          temp_num = (last_num_of_first_ant + i) % N
          if temp_num == 0:
              temp_num = N
          res.append([pos, temp_num])
  
      res.sort(key=lambda x: x[1])
  else:
      for i, pos in enumerate(last_ant_pos):
          temp_num = (last_num_of_first_ant - i) % N
          if temp_num == 0:
              temp_num = N
          res.append([pos, temp_num])
  
      res.sort(key=lambda x: x[1], reverse=True)
  
  
  # print(first_ant)
  # print(num_of_reverse_ant)
  # print(reverse_ant_pos)
  # print('collison', cnt)
  # print('first ant of pos, num',last_pos_of_first_ant, last_num_of_first_ant)
  # print(last_ant_pos)
  # print(res)
  # print('-------ans--------')
  print(*[item[0] for item in res])
  
problem_description: Statement
  
  There is a circle with a circumference of L. Each point on the circumference
  has a coordinate value, which represents the arc length from a certain
  reference point clockwise to the point. On this circumference, there are N
  ants. These ants are numbered 1 through N in order of increasing coordinate,
  and ant i is at coordinate X_i.
  
  The N ants have just started walking. For each ant i, you are given the
  initial direction W_i. Ant i is initially walking clockwise if W_i is 1;
  counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per
  second. Sometimes, two ants bump into each other. Each of these two ants will
  then turn around and start walking in the opposite direction.
  
  For each ant, find its position after T seconds.
samples: [{"input": "3 8 3\n    0 1\n    3 2\n    6 1", "output": "1\n    3\n    0\n    \n\n1.5 seconds after the ants start walking, ant 1 and 2 bump into each other at\ncoordinate 1.5. 1 second after that, ant 1 and 3 bump into each other at\ncoordinate 0.5. 0.5 seconds after that, that is, 3 seconds after the ants\nstart walking, ants 1, 2 and 3 are at coordinates 1, 3 and 0, respectively.\n\n* * *"}, {"input": "4 20 9\n    7 2\n    9 1\n    12 1\n    18 1", "output": "7\n    18\n    18\n    1"}]