#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <vector>

using namespace std;
typedef long long LL;
const int maxn = 100005;
const int mod = 1e9+7;

int L,n,T,a[maxn],w[maxn],x[maxn];LL cur;
int main()
{
	#ifdef Amberframe
		freopen("agc013c.in","r",stdin);
		freopen("agc013c.out","w",stdout);
	#endif
	scanf("%d %d %d",&n,&L,&T);
	for (int i=0;i<n;i++)
	{
		scanf("%d %d",&a[i],&w[i]);
		if (w[i]==1) {
			x[i]=(a[i]+T)%L;
			cur+=(a[i]+T)/L;
		}
		else {
			x[i]=(a[i]-T)%L;
			cur+=(a[i]-T)/L;
			if (x[i]<0) x[i]+=L,cur--;
		}
	}
	cur=(cur%n+n)%n;sort(x,x+n);
	for (int i=cur;i<n;i++) printf("%d\n",x[i]);
	for (int i=0;i<cur;i++) printf("%d\n",x[i]);
	return 0;
}