object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(n, l, t) = readLine().split(" ").map(_.toInt)
    val ants = (1 to n).map(i => {
      val Array(x, w) = readLine().split(" ").map(_.toInt)
      Ant(i, x * 2, if (w == 1) Positive else Negative)
    })
    f(l, t * 2, ants).foreach(ant => println(ant.x / 2))
  }

  // t, x は実際の２倍
  // ants は x でソート済み
  def f(l: Int, t: Int, ants: IndexedSeq[Ant]): Seq[Ant] = {
    val time = (ants.sliding(2) ++ Some(List(ants.last, ants.head.copy(x = ants.head.x + l * 2))))
      .filter { case Seq(a1, a2) => a1.d == Positive && a2.d == Negative }
      .map { case Seq(a1, a2) => a2.x - a1.x }
      .min

    if (time < t) {
      f(l, t - time, ants.map(_.after(time, l)).sorted)
    } else {
      ants.map(_.after(t, l)).sortBy(_.i)
    }
  }

}


sealed trait Direction

object Positive extends Direction

object Negative extends Direction

case class Ant(i: Int, x: Int, d: Direction) extends Ordered[Ant] {
  def after(t: Int, l: Int): Ant = {
    val nextX = this.x + t
    if (2 * l <= nextX) {
      this.copy(x = nextX - 2 * l)
    } else {
      this.copy(x = nextX)
    }
  }

  override def compare(that: Ant): Int = {
    if (this.x < that.x) {
      -1
    } else if (that.x < this.x) {
      1
    } else {
      if (this.d == that.d) {
        0
      } else if (this.d == Positive) {
        1
      } else {
        -1
      }
    }
  }
}
