#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define f first
#define s second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 100500;

int n, w[N];
ll L, T, xa[N];

ll sred(ll x, ll y){
	if(x <= y)
		return (x + y) / 2;
	y += L;
	return ((x + y) / 2) % L;
}

ll dist(ll x, ll y, int W){
	if(W == 2)
		swap(x, y);
	if(x <= y)
		return y - x;
	return L - (x - y);
}

ll get(int num, ll t2){
	ll t1 = 0;
	queue <int> q1, q2;
	for(int i = 1; i < n; ++i)
		if(w[(num - i + n) % n] == 1)
			q1.push(xa[(num - i + n) % n]);
	for(int i = 1; i < n; ++i)
		if(w[(num + i) % n] == 2)
			q2.push(xa[(num + i) % n]);
	ll x = xa[num], W = w[num];
	while(t1 < t2){
		if(W == 1){
			if(q2.empty()){
				x += (t2 - t1);
				x %= L;
				break;
			}
			ll y = q2.front();
			q2.pop();
			y -= t1;
			y %= L;
			y += L;
			y %= L;
			ll z = sred(x, y);
			ll ti = dist(x, z, 1);    
			if(t1 + ti >= t2){
				x += (t2 - t1);
				x %= L;
				break;
			}
			t1 += ti;
			q1.push((((z - t1) % L) + L) % L);
			t1++;
			x = z;
			x = ((x - 1) + L) % L;
		}else{
		    if(q1.empty()){
		    	x -= (t2 - t1);
		    	x %= L;
		    	x += L;
		    	x %= L;
		    	break;
		    }
		    ll y = q1.front();
		    q1.pop();
		    y += t1;
		    y %= L;
		    ll z = sred(y, x);
		    ll ti = dist(x, z, 2);
		    
		    if(t1 + ti >= t2){
		    	x -= (t2 - t1);
		    	x %= L;
		    	x += L;
		    	x %= L;
		    	break;
		    }
		    t1 += ti;
			q2.push((z + t1) % L);
			x = z;
			x = (x + 1) % L;
			t1++;
		}
		W = 3 - W;
	}
	return x;
}

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);

	//cout << setprecision(5) << fixed;

	cin >> n >> L >> T;
	L *= 2;
	T *= 2;

	for(int i = 0; i < n; ++i){
		cin >> xa[i] >> w[i], xa[i] *= 2;
		//xa[i] = i + i;
		//w[i] = i % 2 + 1;
	}

	int shift = lower_bound(xa, xa + n, get(0, L)) - xa;
	
	shift = 1LL * shift * (T / L) % n;
	T %= L;

	ll fir = get(shift, T), sec = get((shift + 1) % n, T);

	for(int i = 0; i < n; ++i){
		if(w[i] == 1)
			xa[i] = (xa[i] + T) % L;
		else xa[i] = (xa[i] - T + L) % L;
	}
	sort(xa, xa + n);

	for(int i = 0; i < n; ++i){
		if(xa[i] == fir && xa[(i + 1) % n] == sec){
			for(int j = i; j < n; ++j)
				cout << xa[j] / 2 << endl;
			for(int j = 0; j < i; ++j)
				cout << xa[j] / 2 << endl;
			return 0;	
		}
	}	

	assert(0);
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}

Measured memory_bytes: 2532