#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  long n, l, t;
  std::vector<std::array<long, 2>> xs;
  Solver() {
    S002 reader;
    reader >= n >= l >= t >n>= xs;
  }
  void solve() {
    std::vector<long> coords;
    for(long i = 0; i < n; ++i) {
      auto x = xs[i];
      long next = -1;
      if( x[1] == 1 ) {
        next = (x[0] + t) % l;
      }
      else if( x[1] == 2 ) {
        assert( (x[0] - t + 1100100100 * l) >= 0 );
        next = (x[0] - t + 1100100100 * l) % l;
      }
      else assert(0);
      coords.push_back(next);
    }
    std::sort(coords.begin(), coords.end());
    assert( coords[0] >= 0 );
    for(long i = 0; i < n; ++i) {
      dumpll(i, coords[i]);
    }
    long count = 0;
    for(long i = 0; i < n; ++i) {
      if( xs[i][1] == 1 ) count += 1;
      else count -= 1;
    }
    long diff = t / l * count;
    for(long i = 0; i < n; ++i) {
      // t % l sec
      long dt = t % l;
      if( xs[i][1] == 1 ) {
        long t1 = ((l-1) - xs[i][0] + 3 * l) % l;
        long t2 = (0     - xs[i][0] + 3 * l) % l;
        if( t1 <= dt and
            t2 <= dt and
            t1 < t2      ) {
          diff += 1;
        }
      }
      if( xs[i][1] == 2 ) {
        long t1 = (xs[i][0] - 0     + 3 * l) % l;
        long t2 = (xs[i][0] - (l-1) + 3 * l) % l;
        if( t1 <= dt and
            t2 <= dt and
            t1 < t2      ) {
          diff -= 1;
        }
      }
    }
    dumpl(diff);
    for(long i = 0; i < n; ++i) {
      
      assert( (i+diff+1100100100*n) >= 0 );
      printf("%ld\n", coords.at((i+diff+1100100100*n)%n));
    }
  }    
  ~Solver() { fprintf(stderr, "--end--\n"); }
};
 

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 3700