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

int n,L,T,a[N],b[N],p[N],ans[N];
bool cmp(int x,int y){
	return (x-b[1]+L)%L<(y-b[1]+L)%L;
}
int main(){
	scanf("%d%d%d",&n,&L,&T);
	int i,x,y;
	for (i=1; i<=n; i++) scanf("%d%d",&a[i],&p[i]);
	for (i=1; i<=n; i++)
		if (p[i]==1) b[i]=(a[i]+T)%L;
		else b[i]=((a[i]-T)%L+L)%L;
	if (n>1) sort(b+2,b+n+1,cmp);
	T<<=1;
	if (p[1]==1){
		for (i=2,x=1; i<=n; i++) if (p[i]==2){
			y=(a[i]-a[1]+L)%L;
			if (T>y) x=(x+1+(T-y-1)/L)%n;
		}
	} else{
		for (i=2,x=1; i<=n; i++) if (p[i]==1){
			y=(a[1]-a[i]+L)%L;
			if (T>=y) x=(x-1-(T-y)/L)%n;
		}
		x=(x+n)%n;
	}
	if (!x) x=n;
	for (i=1; i<=n; i++,x=x%n+1) ans[x]=b[i];
	for (i=1; i<=n; i++) printf("%d\n",ans[i]);
	return 0;
}
