#include<cassert>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define fk(a, b) for(int k=a;k<b;++k)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> pll;
//////////

int const N = 1e5 + 41;
ll const INF = 2e9 * 4LL + 41;

vector<pll> a, b;
ll n, l, t;
int posb[N], posa[N];

void solveSpecial(){
	ll sign = (sz(a) ? 1 : -1);
	if(sz(a) == 0) a = b;
	fi(0, sz(a)){
		ll nx = a[i].first + sign * (t % l);
		nx %= l;
		if(nx < 0) nx += l;
		cout << nx << endl;
	}
	exit(0);
}

void findPoses(){
	bool was = false;
	int rp = 0;
	fi(0, sz(a)){
		while(!was && a[i].first > b[rp].first){
			++rp;
			rp %= sz(b);
			if(rp == 0) was = true;
		}
		posa[i] = rp;
	}

	was = false;
	int lp = sz(a) - 1;
	for(int i=sz(b)-1;i>=0;--i){
		while(!was && b[i].first < a[lp].first){
			--lp;
			if(lp < 0) lp = sz(a) - 1;
			if(lp == sz(a) - 1) was = true;
		}
		posb[i] = lp;
	}
}

ll prefA[N], prefB[N];

void build(){
	prefA[0] = a[0].first + (l - a.back().first);
	fi(1, sz(a)){
		prefA[i] = prefA[i-1] + (a[i].first - a[i-1].first);
	}

	prefB[0] = b[0].first + (l - b.back().first);
	fi(1, sz(b)){
		prefB[i] = prefB[i-1] + (b[i].first - b[i-1].first);
	}
}

ll getA(int pos, ll cnt){
	ll ret = 0;
	ret += l * (cnt / sz(a));
	cnt %= sz(a);
	int mini = pos - cnt;
	if(mini < -1){
		ret += prefA[pos];
		pos = mini + sz(a);
		ret += prefA[sz(a)-1] - prefA[pos];
	}else if(mini == -1){
		ret += prefA[pos];
	}else{
		ret += prefA[pos] - prefA[mini];
	}
	return ret;
}

ll getB(int pos, ll cnt){
	ll ret = 0;
	ret = l * (cnt / sz(b));
	cnt %= sz(b);
	int maxi = cnt + pos;
	if(maxi >= sz(b)){
		ret += prefB[sz(b)-1] - prefB[pos];
		pos = maxi - sz(b);
		ret += prefB[pos];
	}else{
		ret += prefB[maxi] - prefB[pos];
	}
	return ret;
}

ll getKth(int p, ll cnt, vector<pll> &v){
	cnt %= sz(v);
	p += cnt;
	p %= sz(v);
	if(p < 0) p += sz(v);
	return p;
}

ll getPosAfter(ll x, ll cnt){
	cnt %= l;
	x += cnt;
	x %= l;
	if(x < 0) x += l;
	return x;
}

ll ans[N], ansPos[N];

ll getWay(ll a, ll b){
	if(b >= a) return b - a;
	else return (b + l - a);
}

void solveA(){
	fi(0, sz(a)){
		int id = a[i].second;
		ll l = -1;
		ll r = INF;
		while(r-l>1){
			ll m = (l+r)/2;
			ll curWay = getWay(a[i].first, b[posa[i]].first);
			curWay += getA(i, (m+1)/2);
			curWay += getB(posa[i], m/2);
			assert(curWay >= 0);
			if(curWay <= t) l = m;
			else r = m;
		}
		if(l % 2 == 0){
			int k = getKth(posa[i], l/2, b);
			ans[id] = getPosAfter(b[k].first, -(t/2));
		}else{
			int k = getKth(i, -(l+1)/2, a);
			ans[id] = getPosAfter(a[k].first, (t/2));
		}
	}
}

void solveB(){
	fi(0, sz(b)){
		int id = b[i].second;
		ll l = -1;
		ll r = INF;
		while(r-l>1){
			ll m = (l+r)/2;
			ll curWay = getWay(a[posb[i]].first, b[i].first);
			curWay += getA(posb[i], m/2);
			curWay += getB(i, (m+1)/2);
			assert(curWay >= 0);
			if(curWay <= t) l = m;
			else r = m;
		}
		if(l % 2 == 0){
			int k = getKth(posb[i], -(l/2), a);
			ans[id] = getPosAfter(a[k].first, (t/2));
		}else{
			int k = getKth(i, (l+1)/2, b);
			ans[id] = getPosAfter(b[k].first, -(t/2));
		}
	}
}

void solve(){
	cin >> n >> l >> t;
	fi(0, n){
		ll wi, xi;
		cin >> xi >> wi;
		if(wi == 1) a.pb(mp(xi, i));
		else b.pb(mp(xi, i));
	}
	if(sz(a) == 0 || sz(b) == 0) solveSpecial();
	findPoses();
	build();
	t *= 2;
	solveA();
	solveB();
	fi(0, n) cout << ans[i] << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();


	return 0;
}

Measured memory_bytes: 4972