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

const int N = 200010;

int n, t, pos[N], w[N], l, lis[N];
int main() {
	scanf("%d%d%d", &n, &l, &t);
	for (int i = 1; i <= n; ++i) {
		scanf("%d%d", &lis[i], &w[i]);
		pos[i] = lis[i];
		if (w[i] == 2) pos[i] -= t;
		else pos[i] += t;
		if (pos[i] < 0) pos[i] += (abs(pos[i]) + l - 1) / l * l;
		pos[i] %= l;
	}
	
	int cnt = 0;
	for (int i = 2; i <= n; ++i) {
		if (w[i] != w[1]) {
			if (w[1] == 1) {
				int del = lis[i] - lis[1];
				if (2 * t >= del) cnt = cnt + (2 * t - del) / l + 1;
			}
			else {
				int del = l - (lis[i] - lis[1]);
				if (2 * t >= del) cnt = cnt + (2 * t - del) / l + 1;
			}
		}
	}

	int p = pos[1], q;
	if (w[1] == 1) q = 1 + cnt % n;
	else q = (cnt % n == 0 ? 1 : 1 - cnt % n + n);
	
	sort(pos + 1, pos + n + 1);
	for (int i = 1; i <= n; ++i) pos[i + n] = pos[i];
	
	
	cnt = 0;
	for (int i = q; i <= 2 * n; ++i) {
		if (pos[i] == p) {
			int start;
			if (pos[i + 1] == p) start = w[1] == 1 ? i + 1 : i;
			else start = i;
			for (int j = start - q + 1; j - start + q - 1 < n; ++j) {
				printf("%d\n", pos[j]);
			}
			break;
		}
	}
}