#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cassert>
#define rep(i, a, b) for (int i = (a); i <= (b); ++ i)
#define per(i, a, b) for (int i = (a); i >= (b); -- i)
#define For(i, a, b) for (int i = (a); i < (b); ++ i)
#define foreach(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)
#define fore(e, x, y) for (int ep = e(x), y = e[ep].y; ep; y = e[ep = e[ep].nxt].y)
using namespace std;
const int N = 1e5 + 7;
inline int ri() {
int x = 0; bool f = 1; char c = getchar();
for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
return f ? x : -x;
}
int n, L, T;
int X[N], W[N], id[N];
inline int pls(int x, int y, int Mod) {return (x + y) % Mod;}
inline int mul(int x, int y ,int Mod) {return 1LL * x * y % Mod;}
int main() {
#ifndef ONLINE_JUDGE
freopen("a.in", "r", stdin);
#endif
srand(33);
n = ri(), L = ri(), T = ri();
rep (i, 1, n)
X[i] = ri(), W[i] = ri();
int cur = 0, t;
rep (i, 1, n) {
int tms = (T + (W[i] == 1 ? X[i] : L - 1 - X[i])) / L;
cur = pls(cur, mul((W[i] == 1 ? n - 1 : 1), tms, n), n);
}
rep (i, 1, n) X[i] = pls(X[i], mul((W[i] == 1 ? 1 : L - 1), T, L), L);
sort(X+1, X+n+1);
rep (i, n - cur + 1, n) printf("%d\n", X[i]);
rep (i, 1, n - cur) printf("%d\n", X[i]);
return 0;
}