stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <iostream>

#include <cstring>

#include <map>

using namespace std;

int main()

{

    char s[100000 + 10];

    cin>>s;



    if(strlen(s) == 2){

        if(s[0] == s[1]) cout<<1<<" "<<2<<endl;

        else cout<<-1<<" "<<-1<<endl;

        return 0;

    }



    bool ok = false;

    for(int i = 0; s[i + 2]; i++){

        map<char, int> m;

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

            m[s[i + j]]++;

            if(m[s[i + j]] > 1) ok = true;

        }

        if(ok){

            cout<<i + 1<<" "<<i + 3<<endl;

            return 0;

        }

    }



    cout<<-1<<" "<<-1<<endl;



    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<math.h>

#define pi acos(-1.0)

using namespace std;

int main() {

	int s = -1, e = -1;

	char str[100000+5];

	scanf("%s", str);

	int len = strlen(str);

	for(int i = 0; str[i]; i++) {

		if(str[i] == str[i + 1]) {

			s = i + 1;

			e = i + 2;

			break;

		} else if(str[i] == str[i + 2]) {

			s = i + 1;

			e = i + 3;

			break;

		}

	}

	printf("%d %d\n",s,e);	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cstring>

using namespace std;

int main()

{

	string s;

	cin>>s;

	int flag=0;

	for(int i=0;i<s.size()-1;i++)

	{

		if(s[i]==s[i+1])

		{

			cout<<i+1<<" "<<i+2<<endl;

			flag=1;

			break;

		}

		else if(i<s.size()-2&&s[i]==s[i+2])

		{

			cout<<i+1<<" "<<i+3<<endl;

			flag=1;

			break; 

		}

	}

	if(flag==0)

	cout<<-1<<" "<<-1<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<math.h>

#define pi acos(-1.0)

using namespace std;

int main() {

	int s = -1, e = -1;

	char str[100000+5];

	scanf("%s", str);

	int len = strlen(str);

	for(int i = 0; str[i]; i++) {

		if(str[i] == str[i + 1]) {

			s = i + 1;

			e = i + 2;

			break;

		} else if(str[i] == str[i + 2]) {

			s = i + 1;

			e = i + 3;

			break;

		}

	}

	printf("%d %d\n",s,e);	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<functional>

#include <algorithm>

#include  <iostream>

#include   <ctype.h>

#include   <cstring>

#include   <fstream>

#include    <cstdio>

#include    <vector>

#include    <string>

#include     <cmath>

#include     <deque>

#include     <stack>

#include     <queue>

#include      <list>

#include       <set>

#include       <map>

#define INF 0X7FFFFFFF

#define PI acos(-1.0)

typedef long long ll;

using namespace std;

const int N = 1e6;

inline int getint()

{

	int w = 0, q = 0;

	char c = getchar();

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

	if (c == '-') q = 1, c = getchar();

	while (c >= '0'&&c <= '9') w = w * 10 + c - '0', c = getchar();

	return q ? -w : w;

}

string s;

int main() {

	cin >> s;

	int a = -1, b = -1;

	for (int i = 0; i < s.size() && a == -1; i++) {

		if (i + 1 < s.size() && s[i] == s[i + 1]) {

			a = i + 1;

			b = i + 2;

			break;

		}

		if (i + 2 < s.size() && s[i] == s[i + 2]) {

			a = i + 1;

			b = i + 3;

			break;

		}

	}

	cout << a << " " << b << endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<math.h>

#define pi acos(-1.0)

using namespace std;

int main() {

	int s = -1, e = -1;

	char str[100000+5];

	scanf("%s", str);

	int len = strlen(str);

	for(int i = 0; str[i]; i++) {

		if(str[i] == str[i + 1]) {

			s = i + 1;

			e = i + 2;

			break;

		} else if(str[i] == str[i + 2]) {

			s = i + 1;

			e = i + 3;

			break;

		}

	}

	printf("%d %d\n",s,e);	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#include<queue>

#include<vector>

#include<stack>

#include<map>

#include<set>

#include<cmath>

#include<cctype>

#include<ctime>



using namespace std;



int main()

{

    int flag=0;

    char s[100005];

    scanf("%s",s);

    for(int i=0;i<strlen(s);i++)

    {

        if(s[i]==s[i+1])

        {

            printf("%d %d\n",i+1,i+2);

            flag=1;

            break;

        }

        else if(i<strlen(s)-1&&s[i]==s[i+2])

        {

            printf("%d %d\n",i+1,i+3);

            flag=1;

            break;

        }

    }

    if(!flag) printf("-1 -1\n");

    return 0;    

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<math.h>

#define pi acos(-1.0)

using namespace std;

int main() {

	int s = -1, e = -1;

	char str[100000+5];

	scanf("%s", str);

	int len = strlen(str);

	for(int i = 0; str[i]; i++) {

		if(str[i] == str[i + 1]) {

			s = i + 1;

			e = i + 2;

			break;

		} else if(str[i] == str[i + 2]) {

			s = i + 1;

			e = i + 3;

			break;

		}

	}

	printf("%d %d\n",s,e);	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

#include<cstring>

#include<cstdio> 

char s[1010000];

int gs[1010];

int pre[1010];

int main()

{

	while(scanf("%s",s)!=EOF)

	{

		int len=strlen(s);

		memset(gs,0,sizeof(gs));

		memset(pre,0,sizeof(pre));

		int l=-1,r=-1;

		for (int i=0;i<len;i++)

		{

			if (gs[s[i]]!=0)

			{

				if (i-pre[s[i]]<=2)

				{

					l=pre[s[i]]+1;

					r=i+1;

					break;

				}

			}

			gs[s[i]]++;

			pre[s[i]]=i;

		}

		cout<<l<<" "<<r<<endl;

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<math.h>

#define pi acos(-1.0)

using namespace std;

int main() {

	int s = -1, e = -1;

	char str[100000+5];

	scanf("%s", str);

	int len = strlen(str);

	for(int i = 0; str[i]; i++) {

		if(str[i] == str[i + 1]) {

			s = i + 1;

			e = i + 2;

			break;

		} else if(str[i] == str[i + 2]) {

			s = i + 1;

			e = i + 3;

			break;

		}

	}

	printf("%d %d\n",s,e);	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<algorithm>

#include<cstring>

#include<set>

using namespace std;



const int M=1e5+10;

char a[M];



int main(){

    while(scanf("%s",a)!=EOF){

        getchar();

        int flag=0;

        for(int i=1;a[i];i++){

           if(a[i]==a[i-1]){

                printf("%d %d\n",i,i+1);

                 flag=1;

                break;

            }

            else

                if(a[i-1]==a[i+1]){

                    printf("%d %d\n",i,i+2);

                    flag=1;

                    break;

                }

        }

        if(!flag)

            printf("-1 -1\n");

    }

    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<math.h>

#define pi acos(-1.0)

using namespace std;

int main() {

	int s = -1, e = -1;

	char str[100000+5];

	scanf("%s", str);

	int len = strlen(str);

	for(int i = 0; str[i]; i++) {

		if(str[i] == str[i + 1]) {

			s = i + 1;

			e = i + 2;

			break;

		} else if(str[i] == str[i + 2]) {

			s = i + 1;

			e = i + 3;

			break;

		}

	}

	printf("%d %d\n",s,e);	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cstring>

using namespace std;

char s[100010];

int a[100010][30];

int main()

{

	while(scanf("%s",s)!=EOF)

	{

		bool p=false;

		int l=strlen(s),i;

		if(l==2)

		{

			if(s[0]==s[1])

			{

				printf("1 2\n");

				continue;

			}

		}

		else

		for(i=2;i<l;i++)

		{

			if(s[i]==s[i-1]||s[i]==s[i-2])

			{

				p=true;

				break;

			}

		}

		if(p)

		{

			printf("%d %d\n",i-1,i+1);

		}

		else

		printf("-1 -1\n");

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<math.h>

#define pi acos(-1.0)

using namespace std;

int main() {

	int s = -1, e = -1;

	char str[100000+5];

	scanf("%s", str);

	int len = strlen(str);

	for(int i = 0; str[i]; i++) {

		if(str[i] == str[i + 1]) {

			s = i + 1;

			e = i + 2;

			break;

		} else if(str[i] == str[i + 2]) {

			s = i + 1;

			e = i + 3;

			break;

		}

	}

	printf("%d %d\n",s,e);	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<vector>

#include<queue>

#include<utility>

#include<stack>

#include<algorithm>

#include<cstring>

#include<string>

using namespace std;

const int maxn = 1e5 + 5;

char str[maxn];

int main() {

	int s = -1, e = -1;

	scanf("%s", str);

	int len = strlen(str);

	for(int i = 0; str[i]; i++) {

		if(str[i] == str[i + 1]) {

			s = i + 1;

			e = i + 2;

			break;

		} else if(str[i] == str[i + 2]) {

			s = i + 1;

			e = i + 3;

			break;

		}

	}

	cout << s << ' ' << e << '\n';

	return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<math.h>

#define pi acos(-1.0)

using namespace std;

int main() {

	int s = -1, e = -1;

	char str[100000+5];

	scanf("%s", str);

	int len = strlen(str);

	for(int i = 0; str[i]; i++) {

		if(str[i] == str[i + 1]) {

			s = i + 1;

			e = i + 2;

			break;

		} else if(str[i] == str[i + 2]) {

			s = i + 1;

			e = i + 3;

			break;

		}

	}

	printf("%d %d\n",s,e);	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cstring>

using namespace std;



char s[100017];



void solve(){

    int len=strlen(s);

    if(len<2){

        printf("-1 -1\n");

        return ;

    }

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

        if(s[i]==s[i+1]){

            printf("%d %d\n",i+1,i+2);

            return ;

        }else if(s[i]==s[i+2]){

            printf("%d %d\n",i+1,i+3);

            return ;

        }

    }

    printf("-1 -1\n");

        return ;

}



int main(){

    memset(s,0,sizeof(s));

    scanf("%s",s);

    solve();

    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<math.h>

#define pi acos(-1.0)

using namespace std;

int main() {

	int s = -1, e = -1;

	char str[100000+5];

	scanf("%s", str);

	int len = strlen(str);

	for(int i = 0; str[i]; i++) {

		if(str[i] == str[i + 1]) {

			s = i + 1;

			e = i + 2;

			break;

		} else if(str[i] == str[i + 2]) {

			s = i + 1;

			e = i + 3;

			break;

		}

	}

	printf("%d %d\n",s,e);	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <cstdio>

#include <string>



using namespace std;



int main() {

    char buf[131072];

    scanf("%s", buf);

    string s(buf);

    size_t ub=s.length();

    s += '$';



    for (size_t i=0; i<ub; ++i)

        for (size_t j=1; j<=2; ++j)

            if (s[i] == s[i+j]) {

                printf("%llu %llu\n", i+1, i+j+1);

                return 0;

            }



    printf("-1 -1\n");

    return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>



using namespace std;



int main() {

    char s[131072]={};

    scanf("%s", s);

    size_t ub=strlen(s);

    s[ub] = '$';



    for (size_t i=0; i<ub; ++i)

        for (size_t j=1; j<=2; ++j)

            if (s[i] == s[i+j]) {

                printf("%llu %llu\n", i+1, i+j+1);

                return 0;

            }



    printf("-1 -1\n");

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

string s;

int main() {

	cin >> s;

	int l = -1, r = -1;

	for(int i = 1; i < s.size(); i++) {

		if(s[i - 1] == s[i]) l = i, r = i + 1;

	}

	for(int i = 2; i < s.size(); i++) {

		if(s[i - 2] == s[i]) l = i - 1, r = i + 1;

	}

	cout << l << ' ' << r << endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

char s[100009];

int main() {

	scanf("%s", s);

	int l = -1, r = -1;

	for(int i = 1; s[i]; i++) if(s[i - 1] == s[i]) l = i, r = i + 1;

	for(int i = 2; s[i]; i++) if(s[i - 2] == s[i]) l = i - 1, r = i + 1;

	printf("%d %d\n", l, r);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

#include <sstream>

#include <iomanip>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <cctype>

#include <cstring>

#include <vector>

#include <list>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <algorithm>

#include <iterator>

#include <bitset>

#include <ctime>

#include<complex>

using namespace std;



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

#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)

#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a,value) memset(a, value, sizeof(a))



#define SZ(a) (int)a.size()

#define ALL(a) a.begin(), a.end()

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef vector<int> VI;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

const int INF = 1000 * 1000 * 1000 + 7;

const LL LINF = INF * (LL)INF;



const int MAX = 1000 * 100 + 47;



int Y[MAX];

int X[MAX];

int W[MAX];

int t, l;



int getD(int x, int y, int d)

{

	if (d == 2) swap(x, y);

	if (x <= y) return y - x;

	return y + l - x;

}



int main()

{

	//freopen("in.txt", "r", stdin);

	//freopen("out.txt", "w", stdout);

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

	int n;

	cin >> n >> l >> t;

	FOR(i, 0, n)

	{

		cin >> X[i] >> W[i];

	}



	FOR(i, 0, n)

	{

		if (W[i] == 1)

		{

			Y[i] = (X[i] + t) % l;

			//Y[i] = MP((X[i] + t) % l, W[i]);

		}

		else

		{

			Y[i] = (X[i] - t % l + l) % l;

			//Y[i] = MP((X[i] - t % l + l) % l, W[i]);

		}

	}



	int cnt = 0;

	FOR(i, 1, n)

	{

		if (W[i] == W[0]) continue;

		int d = getD(X[0], X[i], W[0]);

		int c = (2 * t - d) / l;

		//if ((2 * t - d) % l == 0) c--;

		//if (c == -1) c = n - 1;

		if (d <= 2 * t) c++;

		c = c % n;

		cnt = (c + cnt) % n;

	}



	if (W[0] == 2) cnt = n - cnt;

	int y = Y[0];

	sort(Y, Y + n);

	int ind = lower_bound(Y, Y + n, y) - Y;

	if (ind + 1 < n && Y[ind] == Y[ind + 1])

	{

		if (W[0] == 1) ind++;

	}



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

	FOR(i, 0, n)

	{

		if (ind == n) ind = 0;



		cout << Y[ind] << "\n";

		ind++;

	}

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;

const int MAXN=(int)1e5+10;

int N,L,T,X,W;int a[MAXN],m;

int main (){

    scanf ("%d%d%d",&N,&L,&T);

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

        scanf ("%d%d",&X,&W);

        if (W==2) W=-1;

        int tpp=X+T*W;

        a[N-1-tp]=((tpp%L)+L)%L;

        m+=tpp/L;if (tpp%L<0)m--;

    }m=((m%N)+N)%N;sort(a,a+N);

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

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

    }for (int i=0;i<m;i++){

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

    }return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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 ] );

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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]);

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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]);

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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]);

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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]);

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem: