#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main()
{
    ll n, l, t;
    cin >> n >> l >> t;
    ll x[100002];
    int w[100002];
    ll ans[100002];
    P left[100002], right[100002];
    ll le = 0, ri = 0;
    for(ll i = 0; i < n; i++){
        cin >> x[i] >> w[i];
        if(w[i] == 1){
            ans[i] = (x[i] + t) % l;
            right[ri] = P(x[i], i);
            ri++;
        }
        else{
            ans[i] = (x[i] + l * t - t) % l;
            left[le] = P(x[i], i);
            le++;
        }
    }
    ll ant;
    ll rl;
    t *= 2;
    if(w[0] == 1){
        if(le == 0){
            ant = 0;
            rl = 1;
        }
        else{
            ll biserch = 500000000;
            ll mid = 500000000;
            ll sumt;
            while(true){
                sumt = left[0].first - right[0].first;
                if(sumt > t){
                    ant = 0;
                    goto anspart;
                }
                sumt = sumt + l * (biserch / ri) + l * (biserch / le);
                sumt = sumt + (right[0].first + l - right[(ri - biserch % ri) % ri].first) % l;
                sumt = sumt + left[biserch % le].first - left[0].first;
                if(mid == 1 && sumt <= t) break;
                mid = (mid + 1) / 2;
                if(sumt > t) biserch -= mid;
                else biserch += mid;
            }
            if(sumt == t) rl = 1;
            ant = left[biserch % le].second;
            if(sumt + (right[(ri - biserch % ri) % ri].first + l - right[(ri - biserch % ri - 1) % ri].first - 1) % l + 1 <= t){
                ant = right[(ri - biserch % ri - 1) % ri].second;
            }
            if(sumt + (right[(ri - biserch % ri) % ri].first + ri * l - right[(ri - biserch % ri - 1) % ri].first - 1) % ri + 1 == t){
                rl = 0;
            }
        }
    }
    if(w[0] == 2){
        if(ri == 0){
            ant = 0;
            rl = 0;
        }
        else{
            ll biserch = 500000000;
            ll mid = 500000000;
            ll sumt;
            while(true){
                sumt = left[0].first + l - right[ri - 1].first;
                if(sumt > t){
                    ant = 0;
                    goto anspart;
                }
                sumt = sumt + l * (biserch / le) + l * (biserch / ri);
                sumt = sumt + left[biserch % le].first - left[0].first;
                sumt = sumt + (right[ri - 1].first + l - right[(ri - biserch % ri) - 1].first) % l;
                if(mid == 1 && sumt <= t) break;
                mid = (mid + 1) / 2;
                if(sumt > t) biserch -= mid;
                else biserch += mid;
            }
            if(sumt == t) rl = 0;
            ant = right[(ri - biserch % ri) - 1].second;
            if(sumt + (left[(biserch + 1) % le].first + l - left[biserch % le].first - 1) % l + 1 <= t){
                ant = left[(biserch + 1) % le].second;
            }
            if(sumt + (left[(biserch + 1) % le].first + l - left[biserch % le].first - 1) % l + 1 == t){
                rl = 1;
            }
        }
    }
anspart:
    ll pant = ans[ant];
    sort(ans, ans + n);
    ll want = lower_bound(ans, ans + n, pant) - ans;
    if(ans[want] == ans[(want + 1) % n]){
        if(rl == 0) want++;
    }
    for(ll i = 0; i < n; i++){
        cout << ans[(want + i) % n] << endl;
    }
}

Measured memory_bytes: 6272