stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

#define fo(i,a,b) for(i=a;i<=b;i++)

using namespace std;

#define ll long long

const int maxn=100000+10;

int x[maxn],xx[maxn],w[maxn];

int i,j,k,l,r,s,t,n,m;

ll c;

inline int read()

{

    int k=1;int x=0;

    char ch=getchar();

    while ((ch<'0'||ch>'9')&&ch!='-')ch=getchar();

    if(ch=='-')

    k=-1,ch=getchar();

    while(ch>='0'&&ch<='9')

    x=x*10+ch-'0',ch=getchar();

    return k*x;

}

int main()

{

	n=read(),l=read(),t=read();

	fo(i,1,n)

		x[i]=read(),w[i]=read();

	fo(i,1,n)

	{

		if (w[i]==2) w[i]=-1;

		r=x[i]+w[i]*t;

		if (r>0) (c+=r/l)%=n;

		else if (r<0) (c+=(r+1)/l-1)%=n;

		xx[i]=(r%l+l)%l;

	}

	sort(xx+1,xx+n+1);

	c=(c+n)%n;

	fo(i,c+1,n)

		printf("%d\n",xx[i]);

	fo(i,1,c) printf("%d\n",xx[i]);

}


// Faster C++ solution for the same problem (measured speedup: 5.143529857486923x):
#include <cstdio>

#include <algorithm>

using namespace std;

#define N 100010

int n,l,t,cnt,a[N],w[N];

int main(){

	scanf("%d%d%d",&n,&l,&t);

	for(int i=1;i<=n;++i) scanf("%d%d",&a[i],&w[i]);

	for(int i=1;i<=n;++i){

		int now=a[i];

		if(w[i]==2) w[i]=-1;

		a[i]+=t*w[i];

		cnt+=a[i]/l;

		if(a[i]%l<0) cnt--;

		a[i]=(a[i]%l+l)%l;

	}

	sort(a+1,a+n+1);

	cnt=(cnt%n+n)%n;

	for(int i=1;i<=n;++i) printf("%d\n",a[(i+cnt-1)%n+1]);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define fo(i,a,b) for(i=a;i<=b;i++)

using namespace std;

#define ll long long

const int maxn=100000+10;

int x[maxn],xx[maxn],w[maxn];

int i,j,k,l,r,s,t,n,m;

ll c;

inline int read()

{

    int k=1;int x=0;

    char ch=getchar();

    while ((ch<'0'||ch>'9')&&ch!='-')ch=getchar();

    if(ch=='-')

    k=-1,ch=getchar();

    while(ch>='0'&&ch<='9')

    x=x*10+ch-'0',ch=getchar();

    return k*x;

}

int main()

{

    n=read(),l=read(),t=read();

    fo(i,1,n)

        x[i]=read(),w[i]=read();

    fo(i,1,n)

    {

        if (w[i]==2) w[i]=-1;

        r=x[i]+w[i]*t;

        if (r>0) (c+=r/l)%=n;

        else if (r<0) (c+=(r+1)/l-1)%=n;

        xx[i]=(r%l+l)%l;

    }

    sort(xx+1,xx+n+1);

    c=(c+n)%n;

    fo(i,c+1,n)

        printf("%d\n",xx[i]);

    fo(i,1,c) printf("%d\n",xx[i]);

}

// Faster C++ solution for the same problem (measured speedup: 5.143529857486923x):
#include <cstdio>

#include <algorithm>

using namespace std;

#define N 100010

int n,l,t,cnt,a[N],w[N];

int main(){

	scanf("%d%d%d",&n,&l,&t);

	for(int i=1;i<=n;++i) scanf("%d%d",&a[i],&w[i]);

	for(int i=1;i<=n;++i){

		int now=a[i];

		if(w[i]==2) w[i]=-1;

		a[i]+=t*w[i];

		cnt+=a[i]/l;

		if(a[i]%l<0) cnt--;

		a[i]=(a[i]%l+l)%l;

	}

	sort(a+1,a+n+1);

	cnt=(cnt%n+n)%n;

	for(int i=1;i<=n;++i) printf("%d\n",a[(i+cnt-1)%n+1]);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

const LL MAXN = 1e5 + 5;

LL x[MAXN], w[MAXN], ans[MAXN];

int main(){

	LL n, l, t, i, j = 1;

	scanf("%lld %lld %lld", &n, &l, &t);

	for(i = 1 ; i <= n ; ++i){

		scanf("%lld %lld", &x[i], &w[i]);

		ans[i] = x[i] + (w[i] == 1 ? t : -t);

		ans[i] = (ans[i] % l + l) % l;

	}

	for(i = 1 ; i <= n ; ++i){

		LL r = x[i] + (w[i] == 1 ? t : -t);

		j +=  r / l;

		r %= l;

		if(r < 0) --j;

	}

	sort(ans + 1, ans + 1 + n);

	j = (j % n + n) % n;

	if(j == 0) j = n;

	for(i = j ; i <= n ; ++i)

		printf("%lld\n", ans[i]);

	for(i = 1 ; i < j ; ++i)

		printf("%lld\n", ans[i]);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.198948466833117x):
#include <cstdio>

#include <algorithm>

using namespace std;

#define N 100010

int n,l,t,cnt,a[N],w[N];

int main(){

	scanf("%d%d%d",&n,&l,&t);

	for(int i=1;i<=n;++i) scanf("%d%d",&a[i],&w[i]);

	for(int i=1;i<=n;++i){

		int now=a[i];

		if(w[i]==2) w[i]=-1;

		a[i]+=t*w[i];

		cnt+=a[i]/l;

		if(a[i]%l<0) cnt--;

		a[i]=(a[i]%l+l)%l;

	}

	sort(a+1,a+n+1);

	cnt=(cnt%n+n)%n;

	for(int i=1;i<=n;++i) printf("%d\n",a[(i+cnt-1)%n+1]);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define xx first

#define yy second

#define mp make_pair

#define pb push_back

#define fill( x, y ) memset( x, y, sizeof x )

#define copy( x, y ) memcpy( x, y, sizeof x )

using namespace std;

 

typedef long long LL;

typedef pair < int, int > pa;

 

const int MAXN = 100010;

 

int n, x[MAXN], a[MAXN], w[MAXN], L, T;

LL cur;

 

int main()

{

#ifdef wxh010910

	freopen( "data.in", "r", stdin );

#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 ] );

}


// Faster C++ solution for the same problem (measured speedup: 5.194032348015295x):
#include<cstdio>

#include<algorithm>

using namespace std;

const int N=1e5+10;

int x[N], w[N], ans[N], n, m, t;

long long mi;

int main() {

	scanf("%d%d%d", &n, &m, &t);

	for(int i=1; i<=n; i++) { scanf("%d%d", &x[i], &w[i]); if(w[i]==2) w[i]=-1; }

	int to=0;for(int i=1; i<=n; i++) {to=x[i]+t*w[i]; if(to>0) (mi+=to/m)%=n; if(to<0) (mi+=(to+1)/m-1)%=n; ans[i]=(to%m+m)%m;}

	sort(ans+1, ans+n+1), mi=(mi+n)%n;

	for(int i=mi+1; i<=n; i++) printf("%d\n", ans[i]); for(int i=1; i<=mi; i++) printf("%d\n", ans[i]);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define fo(i,a,b) for(i=a;i<=b;i++)

using namespace std;

#define ll long long

const int maxn=100000+10;

int x[maxn],xx[maxn],w[maxn];

int i,j,k,l,r,s,t,n,m;

ll c;

inline int read()

{

    int k=1;int x=0;

    char ch=getchar();

    while ((ch<'0'||ch>'9')&&ch!='-')ch=getchar();

    if(ch=='-')

    k=-1,ch=getchar();

    while(ch>='0'&&ch<='9')

    x=x*10+ch-'0',ch=getchar();

    return k*x;

}

int main()

{

	n=read(),l=read(),t=read();

	fo(i,1,n)

		x[i]=read(),w[i]=read();

	fo(i,1,n)

	{

		if (w[i]==2) w[i]=-1;

		r=x[i]+w[i]*t;

		if (r>0) (c+=r/l)%=n;

		else if (r<0) (c+=(r+1)/l-1)%=n;

		xx[i]=(r%l+l)%l;

	}

	sort(xx+1,xx+n+1);

	c=(c+n)%n;

	fo(i,c+1,n)

		printf("%d\n",xx[i]);

	fo(i,1,c) printf("%d\n",xx[i]);

}


// Faster C++ solution for the same problem (measured speedup: 5.141501720180814x):
#include<cstdio>

#include<algorithm>

using namespace std;

const int N=1e5+10;

int x[N], w[N], ans[N], n, m, t;

long long mi;

int main() {

	scanf("%d%d%d", &n, &m, &t);

	for(int i=1; i<=n; i++) { scanf("%d%d", &x[i], &w[i]); if(w[i]==2) w[i]=-1; }

	int to=0;for(int i=1; i<=n; i++) {to=x[i]+t*w[i]; if(to>0) (mi+=to/m)%=n; if(to<0) (mi+=(to+1)/m-1)%=n; ans[i]=(to%m+m)%m;}

	sort(ans+1, ans+n+1), mi=(mi+n)%n;

	for(int i=mi+1; i<=n; i++) printf("%d\n", ans[i]); for(int i=1; i<=mi; i++) printf("%d\n", ans[i]);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define fo(i,a,b) for(i=a;i<=b;i++)

using namespace std;

#define ll long long

const int maxn=100000+10;

int x[maxn],xx[maxn],w[maxn];

int i,j,k,l,r,s,t,n,m;

ll c;

inline int read()

{

    int k=1;int x=0;

    char ch=getchar();

    while ((ch<'0'||ch>'9')&&ch!='-')ch=getchar();

    if(ch=='-')

    k=-1,ch=getchar();

    while(ch>='0'&&ch<='9')

    x=x*10+ch-'0',ch=getchar();

    return k*x;

}

int main()

{

    n=read(),l=read(),t=read();

    fo(i,1,n)

        x[i]=read(),w[i]=read();

    fo(i,1,n)

    {

        if (w[i]==2) w[i]=-1;

        r=x[i]+w[i]*t;

        if (r>0) (c+=r/l)%=n;

        else if (r<0) (c+=(r+1)/l-1)%=n;

        xx[i]=(r%l+l)%l;

    }

    sort(xx+1,xx+n+1);

    c=(c+n)%n;

    fo(i,c+1,n)

        printf("%d\n",xx[i]);

    fo(i,1,c) printf("%d\n",xx[i]);

}

// Faster C++ solution for the same problem (measured speedup: 5.141501720180814x):
#include<cstdio>

#include<algorithm>

using namespace std;

const int N=1e5+10;

int x[N], w[N], ans[N], n, m, t;

long long mi;

int main() {

	scanf("%d%d%d", &n, &m, &t);

	for(int i=1; i<=n; i++) { scanf("%d%d", &x[i], &w[i]); if(w[i]==2) w[i]=-1; }

	int to=0;for(int i=1; i<=n; i++) {to=x[i]+t*w[i]; if(to>0) (mi+=to/m)%=n; if(to<0) (mi+=(to+1)/m-1)%=n; ans[i]=(to%m+m)%m;}

	sort(ans+1, ans+n+1), mi=(mi+n)%n;

	for(int i=mi+1; i<=n; i++) printf("%d\n", ans[i]); for(int i=1; i<=mi; i++) printf("%d\n", ans[i]);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

const LL MAXN = 1e5 + 5;

LL x[MAXN], w[MAXN], ans[MAXN];

int main(){

	LL n, l, t, i, j = 1;

	scanf("%lld %lld %lld", &n, &l, &t);

	for(i = 1 ; i <= n ; ++i){

		scanf("%lld %lld", &x[i], &w[i]);

		ans[i] = x[i] + (w[i] == 1 ? t : -t);

		ans[i] = (ans[i] % l + l) % l;

	}

	for(i = 1 ; i <= n ; ++i){

		LL r = x[i] + (w[i] == 1 ? t : -t);

		j +=  r / l;

		r %= l;

		if(r < 0) --j;

	}

	sort(ans + 1, ans + 1 + n);

	j = (j % n + n) % n;

	if(j == 0) j = n;

	for(i = j ; i <= n ; ++i)

		printf("%lld\n", ans[i]);

	for(i = 1 ; i < j ; ++i)

		printf("%lld\n", ans[i]);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.1968984775008344x):
#include<cstdio>

#include<algorithm>

using namespace std;

const int N=1e5+10;

int x[N], w[N], ans[N], n, m, t;

long long mi;

int main() {

	scanf("%d%d%d", &n, &m, &t);

	for(int i=1; i<=n; i++) { scanf("%d%d", &x[i], &w[i]); if(w[i]==2) w[i]=-1; }

	int to=0;for(int i=1; i<=n; i++) {to=x[i]+t*w[i]; if(to>0) (mi+=to/m)%=n; if(to<0) (mi+=(to+1)/m-1)%=n; ans[i]=(to%m+m)%m;}

	sort(ans+1, ans+n+1), mi=(mi+n)%n;

	for(int i=mi+1; i<=n; i++) printf("%d\n", ans[i]); for(int i=1; i<=mi; i++) printf("%d\n", ans[i]);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



#define fo(i,a,b) for(i=a;i<=b;i++)



using namespace std;

#define ll long long

const int maxn=100000+10;

int x[maxn],xx[maxn],w[maxn];

int i,j,k,l,r,s,t,n,m;

ll c;



int read() {

  int ans = 0, c, f = 1;

  while (!isdigit(c = getchar()))

    if (c == '-') f = -1;

  do ans = ans * 10 + c - '0';

  while (isdigit(c = getchar()));

  return ans * f;

}

int main()

{

    n=read(),l=read(),t=read();

    fo(i,1,n)

        x[i]=read(),w[i]=read();

    fo(i,1,n)

    {

        if (w[i]==2) w[i]=-1;

        r=x[i]+w[i]*t;

        if (r>0) (c+=r/l)%=n;

        else if (r<0) (c+=(r+1)/l-1)%=n;

        xx[i]=(r%l+l)%l;

    }

    sort(xx+1,xx+n+1);

    c=(c+n)%n;

    fo(i,c+1,n)

        printf("%d\n",xx[i]);

    fo(i,1,c) printf("%d\n",xx[i]);

}

// Faster C++ solution for the same problem (measured speedup: 5.139145060029878x):
#include<cstdio>

#include<algorithm>

using namespace std;

const int N=1e5+10;

int x[N], w[N], ans[N], n, m, t;

long long mi;

int main() {

	scanf("%d%d%d", &n, &m, &t);

	for(int i=1; i<=n; i++) { scanf("%d%d", &x[i], &w[i]); if(w[i]==2) w[i]=-1; }

	int to=0;for(int i=1; i<=n; i++) {to=x[i]+t*w[i]; if(to>0) (mi+=to/m)%=n; if(to<0) (mi+=(to+1)/m-1)%=n; ans[i]=(to%m+m)%m;}

	sort(ans+1, ans+n+1), mi=(mi+n)%n;

	for(int i=mi+1; i<=n; i++) printf("%d\n", ans[i]); for(int i=1; i<=mi; i++) printf("%d\n", ans[i]);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int maxn=100000+10;

int x[maxn],xx[maxn],w[maxn];

int i,j,k,l,r,s,t,n,m;

long long c;

int main()

{

    cin>>n>>l>>t;

    for(i=1;i<=n;i++) cin>>x[i]>>w[i];

    for(i=1;i<=n;i++) {

        if(w[i]==2) w[i]=-1;

        r=x[i]+w[i]*t;

        if(r>0) (c+=r/l)%=n;

        else if(r<0) (c+=(r+1)/l-1)%=n;

        xx[i]=(r%l+l)%l;

    }

    sort(xx+1,xx+n+1);

    c=(c+n)%n;

    for(i=c+1;i<=n;i++) printf("%d\n",xx[i]);

    for(i=1;i<=c;i++) printf("%d\n",xx[i]);

}

// Faster C++ solution for the same problem (measured speedup: 5.200502597130134x):
#include<cstdio>

#include<algorithm>

using namespace std;

const int N=1e5+10;

int x[N], w[N], ans[N], n, m, t;

long long mi;

int main() {

	scanf("%d%d%d", &n, &m, &t);

	for(int i=1; i<=n; i++) { scanf("%d%d", &x[i], &w[i]); if(w[i]==2) w[i]=-1; }

	int to=0;for(int i=1; i<=n; i++) {to=x[i]+t*w[i]; if(to>0) (mi+=to/m)%=n; if(to<0) (mi+=(to+1)/m-1)%=n; ans[i]=(to%m+m)%m;}

	sort(ans+1, ans+n+1), mi=(mi+n)%n;

	for(int i=mi+1; i<=n; i++) printf("%d\n", ans[i]); for(int i=1; i<=mi; i++) printf("%d\n", ans[i]);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int x[100010],w[100010];

int ans[100010]; 

int n,L,r,t;

long long fldl;

int main()

{

	scanf("%d%d%d",&n,&L,&t);

    for(int i = 1;i <= n;i++)

    {

        scanf("%d%d",&x[i],&w[i]);

		if(w[i] == 2)w[i] = -1;

	}

    for(int i = 1;i <= n;i++)

    {

        int len = x[i] + w[i] * t;

        if (len > 0) (fldl += len / L) %= n;

        else if (len < 0) (fldl += (len + 1) / L - 1) %= n;

        ans[i] = (len % L + L) % L;

    }

    sort(ans + 1 ,ans + n + 1);

    fldl = (fldl + n) % n;

    for(int i = fldl + 1;i <= n;i++)printf("%d\n",ans[i]);

    for(int i = 1;i <= fldl;i++) printf("%d\n",ans[i]);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.1566478129852475x):
#include<cstdio>

#include<algorithm>

using namespace std;

const int N=1e5+10;

int x[N], w[N], ans[N], n, m, t;

long long mi;

int main() {

	scanf("%d%d%d", &n, &m, &t);

	for(int i=1; i<=n; i++) { scanf("%d%d", &x[i], &w[i]); if(w[i]==2) w[i]=-1; }

	int to=0;for(int i=1; i<=n; i++) {to=x[i]+t*w[i]; if(to>0) (mi+=to/m)%=n; if(to<0) (mi+=(to+1)/m-1)%=n; ans[i]=(to%m+m)%m;}

	sort(ans+1, ans+n+1), mi=(mi+n)%n;

	for(int i=mi+1; i<=n; i++) printf("%d\n", ans[i]); for(int i=1; i<=mi; i++) printf("%d\n", ans[i]);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<algorithm>

using namespace std;

long long n,l,t,x,w,ans[100001],p,s;

int main(){

	scanf("%lld%lld%lld",&n,&l,&t);

	for(long long i=1;i<=n;i++){

		scanf("%lld%lld",&x,&w);

        if(w==2)p=x-t;

        else p=x+t;

        if(p>0)s=(s+p/l)%n;

        if(p<0)s=(s+(p+1)/l-1)%n;

        ans[i]=(p%l+l)%l;

    }

    sort(ans+1,ans+n+1);

    if(s>=0)s=s%n;

    else{

    	p=(s+1)/n+1;

    	s=s+p*n;

	}

    for(long long i=s+1;i<=n;i++)printf("%lld\n",ans[i]);

    for(long long i=1;i<=s;i++)printf("%lld\n",ans[i]);

}

// Faster C++ solution for the same problem (measured speedup: 5.15567807175319x):
#include<cstdio>

#include<algorithm>

using namespace std;

const int N=1e5+10;

int x[N], w[N], ans[N], n, m, t;

long long mi;

int main() {

	scanf("%d%d%d", &n, &m, &t);

	for(int i=1; i<=n; i++) { scanf("%d%d", &x[i], &w[i]); if(w[i]==2) w[i]=-1; }

	int to=0;for(int i=1; i<=n; i++) {to=x[i]+t*w[i]; if(to>0) (mi+=to/m)%=n; if(to<0) (mi+=(to+1)/m-1)%=n; ans[i]=(to%m+m)%m;}

	sort(ans+1, ans+n+1), mi=(mi+n)%n;

	for(int i=mi+1; i<=n; i++) printf("%d\n", ans[i]); for(int i=1; i<=mi; i++) printf("%d\n", ans[i]);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define N 100001

using namespace std;

long long c;

int x[N],w[N],ans[N];

int main()

{

	int n,L,t;

    scanf("%d%d%d",&n,&L,&t);

    for(int i=1;i<=n;i++)

    {

        scanf("%d%d",&x[i],&w[i]);

    }

    for(int i=1;i<=n;i++)

    {

        if(w[i]==2)w[i]=-1;

        int r=x[i]+w[i]*t;

        if(r>0) 

        {

        	(c+=r/L)%=n;

		}

        else if(r<0)

        {

        	(c+=(r+1)/L-1)%=n;

		}

        ans[i]=(r%L+L)%L;

    }

    sort(ans+1,ans+n+1);

    c=(c+n)%n;

    for(int i=c+1;i<=n;i++)

    {

        printf("%d\n",ans[i]);

    }

    for(int i=1;i<=c;i++)

    {

       printf("%d\n",ans[i]); 

    }

}

// Faster C++ solution for the same problem (measured speedup: 5.15525386177727x):
#include<cstdio>

#include<algorithm>

using namespace std;

const int N=1e5+10;

int x[N], w[N], ans[N], n, m, t;

long long mi;

int main() {

	scanf("%d%d%d", &n, &m, &t);

	for(int i=1; i<=n; i++) { scanf("%d%d", &x[i], &w[i]); if(w[i]==2) w[i]=-1; }

	int to=0;for(int i=1; i<=n; i++) {to=x[i]+t*w[i]; if(to>0) (mi+=to/m)%=n; if(to<0) (mi+=(to+1)/m-1)%=n; ans[i]=(to%m+m)%m;}

	sort(ans+1, ans+n+1), mi=(mi+n)%n;

	for(int i=mi+1; i<=n; i++) printf("%d\n", ans[i]); for(int i=1; i<=mi; i++) printf("%d\n", ans[i]);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

const int maxn = 100035;



int a[maxn],n,l,t,x,cnt;



int main()

{

    scanf("%d%d%d",&n,&l,&t);

    for (int i=1; i<=n; i++)

    {

        scanf("%d%d",&a[i],&x);

        a[i] += x==1?t:-t;

        cnt += a[i]/l;

        if (a[i]%l<0) cnt--;

        ((a[i]%=l)+=l)%=l;

    }

    std::sort(a+1, a+n+1);

    ((cnt%=n)+=n)%=n;

    for (int i=cnt+1; i<=n; i++) printf("%d\n",a[i]);

    for (int i=1; i<=cnt; i++) printf("%d\n",a[i]);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.239339036333493x):
#include <cstdio>

#include <algorithm>

using namespace std;

 

const int maxn=1e5+5;

 

int n,rk,L,T;

int pos[maxn];

 

int read() {

	int x=0,f=1;char ch=getchar();

	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;

	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';

	return x*f;

}

 

int main() {

	n=read(),L=read(),T=read();

	for(int i=1;i<=n;i++) {

		int x=read(),w=read();

		if(w==2)pos[i]=x-T;

		else pos[i]=x+T;

		rk+=pos[i]/L;

		if(pos[i]%L<0)rk--;

		pos[i]=(pos[i]%L+L)%L;

	}

	sort(pos+1,pos+n+1);

	rk=(rk%n+n)%n;

	for(int i=rk+1;i<=n;i++)

		printf("%d\n",pos[i]);

	for(int i=1;i<=rk;i++)

		printf("%d\n",pos[i]);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int n;

int d[1000000];



string check2(){

  int nowpos=n-1;

  int canhop=n-1;

  int minhop=n-1;



  for(int j=0;j<300000;j++){

    canhop=nowpos-d[nowpos]/10;

    minhop=canhop;

    if(canhop<=0)return "yes";



    for(int i=nowpos;i>=canhop;i--){

      if(i-d[i]/10<minhop){

        nowpos=i;

        minhop=i-d[i]/10;

      }

    }





  }

  return "no";

}



string check1(){

  int nowpos=0;

  int canhop=0;

  int maxhop=0;



  for(int j=0;j<300000;j++){

    canhop=d[nowpos]/10+nowpos;

    maxhop=canhop;

    if(canhop>=n-1)return check2();



    for(int i=nowpos;i<=canhop;i++){

      if(d[i]/10+i>=maxhop){

        nowpos=i;

        maxhop=d[i]/10+i;

      }

    }

  }

  return "no";

}



int main(){

  cin >>n;

  for(int i=0;i<n;i++){

    cin>>d[i];

    int sub=d[i]%10;

    d[i]-=sub;

  }

  cout <<check1()<<endl;

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.8806286073377085x):
#include <bits/stdc++.h>

using namespace std;

int N;

int d[1000000];

string checkprev(){

	int canhop=1;

	for(int i = N-1;i>0;i--){

		canhop--;

		canhop = max(canhop,d[i]/10);

		if(canhop ==0)

			return "no";

	}

	return "yes";

}

string checkfront(){

	int canhop=1;

	for(int i = 0;i<N;i++){

	canhop--;

	canhop = max(canhop,d[i]/10);

	if(canhop ==0)

		return "no";

	}

	return checkprev();

}

int main(){

	cin >> N;

	for(int i = 0;i<N;i++){

		cin >> d[i];

	}

	cout << checkfront()<<endl;

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main () {

	int r;

	cin >> r;

	if (r<1200){

		cout << "ABC" <<endl;

	}

	if (r<2800&&r>=1200){

		cout << "ARC" << endl;

	}

	if (r>=2800&&r<=4208) {

		cout << "AGC" << endl;

	}

	

	return 0;

	



}

// Faster C++ solution for the same problem (measured speedup: 5.31001830373552x):
#include<stdio.h>

int main()

{

	int a;

	scanf("%d",&a);

	if(a<1200){

		printf("ABC\n");

	}

	else if(a<2800){

		printf("ARC\n");

	}

	else{

		printf("AGC\n");

	}

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int R;

int main () {

	cin >> R;

	if (R < 1200) {

	cout << "ABC" << endl;

	}else if (R < 2800) {

	cout << "ARC" << endl;

	}else {

	cout << "AGC" << endl;

}	

return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.310403615402848x):
#include<stdio.h>

int main()

{

	int a;

	scanf("%d",&a);

	if(a<1200){

		printf("ABC\n");

	}

	else if(a<2800){

		printf("ARC\n");

	}

	else{

		printf("AGC\n");

	}

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main () {

	int r;

	cin >> r;

	if (r<1200){

		cout << "ABC" <<endl;

	}

	if (r<2800&&r>=1200){

		cout << "ARC" << endl;

	}

	if (r>=2800&&r<=4208) {

		cout << "AGC" << endl;

	}

	

	return 0;

	



}

// Faster C++ solution for the same problem (measured speedup: 5.310026968139282x):
#include <stdio.h>

int main(){

	int input;

	scanf ("%d", &input);

	if (input<1200){

		printf ("ABC\n");

	}else if (input>=1200&&input<2800){

		printf ("ARC\n");

	}else printf ("AGC\n");

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int R;

int main () {

	cin >> R;

	if (R < 1200) {

	cout << "ABC" << endl;

	}else if (R < 2800) {

	cout << "ARC" << endl;

	}else {

	cout << "AGC" << endl;

}	

return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.310412280435328x):
#include <stdio.h>

int main(){

	int input;

	scanf ("%d", &input);

	if (input<1200){

		printf ("ABC\n");

	}else if (input>=1200&&input<2800){

		printf ("ARC\n");

	}else printf ("AGC\n");

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>

#include <algorithm>

#include <climits>

using namespace std;

int main() {

	cin.tie(0); ios::sync_with_stdio(false);

	long long a, N, s, A = (LLONG_MAX), l = 0, r = 0, S[100002] = { 0 }; cin >> N >> s;

	for (int i = 1; i <= N;i++) { cin >> a;S[i] += S[i - 1] + a; }

	for(;;){

		if (S[r] - S[l] >= s) { A = min(A, r - l); l++; }else r++;

		if (r > N || l > N) { if (A == (LLONG_MAX))A = 0; cout << A << endl; return 0; }

	}

}

// Faster C++ solution for the same problem (measured speedup: 1.8298926791655463x):
#include<bits/stdc++.h>

long long i,a,N,s,A=INT_MAX,l,r,S[100002];int main(){scanf("%ld%ld",&N,&s);for(;i<N;i++){scanf("%ld",&a);S[i+1]+=S[i]+a;}for(;;){if(S[r]-S[l]>=s){A=std::min(A,r-l);l++;}else r++;if(r>N){if(A==INT_MAX)A=0;printf("%ld\n",A);return 0;}}}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int main() {

	long long a, N, s, A = (LLONG_MAX), l = 0, r = 0, S[100002] = { 0 }; cin >> N >> s;

	for (int i = 1; i <= N;i++) { cin >> a;S[i] += S[i - 1] + a; }

	for(;;){

		if (S[r] - S[l] >= s) { A = min(A, r - l); l++; }else r++;

		if (r > N || l > N) { if (A == (LLONG_MAX))A = 0; cout << A << endl; return 0; }

	}

}

// Faster C++ solution for the same problem (measured speedup: 1.8173508186894625x):
#include<bits/stdc++.h>

long long i,a,N,s,A=INT_MAX,l,r,S[100002];int main(){scanf("%ld%ld",&N,&s);for(;i<N;i++){scanf("%ld",&a);S[i+1]+=S[i]+a;}for(;;){if(S[r]-S[l]>=s){A=std::min(A,r-l);l++;}else r++;if(r>N){if(A==INT_MAX)A=0;printf("%ld\n",A);return 0;}}}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;int main(){cin.tie(0);ios::sync_with_stdio(false);long long i,a,N,s,A=LLONG_MAX,l=0,r=0,S[100002]={0};cin>>N>>s;for(i=1;i<=N;i++){cin>>a;S[i]+=S[i- 1]+a;}for(;;){if(S[r]-S[l]>=s){A=min(A,r-l);l++;}else(r++);if(r>N){if(A==LLONG_MAX)A=0;cout<<A<<endl;return 0;}}}

// Faster C++ solution for the same problem (measured speedup: 1.829830897970554x):
#include<bits/stdc++.h>

long long i,a,N,s,A=INT_MAX,l,r,S[100002];int main(){scanf("%ld%ld",&N,&s);for(;i<N;i++){scanf("%ld",&a);S[i+1]+=S[i]+a;}for(;;){if(S[r]-S[l]>=s){A=std::min(A,r-l);l++;}else r++;if(r>N){if(A==INT_MAX)A=0;printf("%ld\n",A);return 0;}}}