#include <bits/stdc++.h>
using namespace std;

#define NDEBUG
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

template <typename T>
inline T mod(T a, T m) {
    T res = a % m;
    if (res < 0) res += m;
    return res;
}


class Solver {
    int N, L, T;
    vi x, dir;

    vi cw, ccw;
    int CW, CCW;
public:
    Solver() {
        scanf("%d%d%d", &N, &L, &T);
        x.resize(N); dir.resize(N);
        rep(i,N) {
            int w;
            scanf("%d%d", &x[i], &w);
            dir[i] = (w == 1) ? 1 : -1;
        }

        init();
        rep(i,N) printf("%d\n", mod(solve1(x[i], dir[i], T), L));
    }
private:
    void init() {
        cw.reserve(N*2); ccw.reserve(N*2);
        rep(i,N){
            if (dir[i] == 1) {
                cw.pb(x[i]);
            } else {
                ccw.pb(x[i]);
            }
        }
        CW = cw.size(); CCW = ccw.size();

        cw.resize(CW*2);
        rep(i,CW) cw[CW+i] = cw[i] + L;
        ccw.resize(CCW*2);
        rep(i,CCW) ccw[CCW+i] = ccw[i] + L;
    }
    ll cw_d(int i, int m){
        int q = m / CW, r = m % CW;
        ll ans = (ll)L * q + (cw[CW+i] - cw[CW+i-r]);
        return ans;
    }
    ll ccw_d(int j, int m){
        int q = m / CCW, r = m % CCW;
        ll ans = (ll)L * q + (ccw[j+r] - ccw[j]);
        return ans;
    }
    int sub(int i, int j, int dir, int T2) {
        int lo=0, hi=1e9;
        while (lo+1 < hi) {
            int m = mid(lo, hi);
            ll d0 = cw_d(i, m) + ccw_d(j, m);
            if (d0 <= T2) {
                lo = m;
            } else {
                hi = m;
            }
        }
        ll dx0 = cw_d(i, lo), dx1 = cw_d(i, lo+1);
        ll dy0 = ccw_d(j, lo), dy1 = ccw_d(j, lo+1);

        ll d0 = dx0 + dy0, d2 = dx1 + dy1;
        ll dx, dy;
        if (dir == -1) {
            ll d1 = dx1 + dy0;

            if (IN(T2, d0, d1-1)) {
                dy = dy0;
                dx = dx0 + (T2 - d0);
            } else if (IN(T2, d1, d2-1)) {
                dy = dy0 + (T2 - d1);
                dx = dx1;
            }
        } else {
            ll d1 = dx0 + dy1;
            if (IN(T2, d0, d1-1)) {
                dy = dy0 + (T2 - d0);
                dx = dx0;
            } else if (IN(T2, d1, d2-1)) {
                dy = dy1;
                dx = dx0 + (T2 - d1);
            }
        }
        return dy - dx;
    }
    int solve1(int x, int dir, int T) {
        if (CW == 0) return x-T;
        else if (CCW == 0) return x+T;

        assert(CW > 0 && CCW > 0);

        if (dir == 1) {
            int me = lower_bound(ALL(cw), x) - cw.begin();
            int ix = mod((int)(lower_bound(ALL(ccw), x) - ccw.begin()), CCW);
            int dx = ccw[ix] - x;
            assert(IN(dx, -(L-1), L-1));
            if (dx < 0) dx += L;
            if (T <= dx/2) {
                return x+T;
            } else {
                ll s = dx + sub(me, ix, -dir, T*2 - dx);
                return x + s/2;
            }
        } else {
            int me = lower_bound(ALL(ccw), x) - ccw.begin();
            int ix = mod((int)(lower_bound(ALL(cw), x) - cw.begin()) - 1, CW);
            int dx = x - cw[ix];
            assert(IN(dx, -(L-1), L-1));
            if (dx < 0) dx += L;
            if (T <= dx/2) {
                return x-T;
            } else {
                ll s = -dx + sub(ix, me, -dir, T*2 - dx);
                return x + s/2;
            }

        }
        return 0;
    }
};

int main() {
    Solver *s = new Solver();
    delete s;
    return 0;
}


Measured memory_bytes: 2816