#include <algorithm>
#include <cstdio>

const int N=100005;
int x[N],w[N],ans[N];

int main(){
	int n,L,T,pos=0;
	scanf("%d%d%d\n",&n,&L,&T);
	for (int i=0;i<n;i++){
		scanf("%d%d\n",&x[i],&w[i]);
		if (w[i]==2) w[i]=-1;
		ans[i]=((x[i]+w[i]*T)%L+L)%L;
	}
	for (int i=1;i<n;i++)
	if (w[i]!=w[0]){
		int t=T*2-((w[0]*(x[i]-x[0])%L+L)%L)-1;
		if (t>=0) pos=(pos+t/L+1)%n;
	}
	pos=(pos*w[0]+n)%n;
	int v=ans[0];
	std::sort(ans,ans+n);
	for (int i=0;i<n;i++)
	if (ans[i]==v){
		i+=(i<n-1 && ans[i]==ans[i+1] && w[0]==-1);
		pos=(i-pos+n)%n;break;
	}
	for (int i=0;i<n;i++) printf("%d\n",ans[(i+pos)%n]);
}