#ifdef __APPLE__
#include <cassert>
#include <iostream>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cctype>
#include <list>
#include <cmath>
#include <limits>
#include <bitset>
#include <numeric>
#include <climits>
#include <complex>
#else
#include<bits/stdc++.h>
#endif // __APPLE__
using namespace std;
typedef pair<int,int>   II;
typedef vector<II>     VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int LL;
typedef  unsigned long long int ULL;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define ALL(c) (c).begin(),(c).end()
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i,a,b) for(int i = (int)a; i < (int)b; i++)
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1)	{
cerr << name << " : " << arg1 << std::endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
     const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif




#define ll long long
#define ld long double
#define N ((ll)301*1000)

struct Ant{
    ll x,y,id;
    int c;
};

bool cmp(Ant x,Ant y){return x.x<y.x;}

ll n,m,t,ans[N],cnt_l;
pair <ll,ll> b[N];
Ant a[N];
ll tmp[N];

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m>>t;
    for(int i=0;i<n;i++)
    {
        cin>>a[i].x>>a[i].c;
        a[i].id=i;
        a[i].y=a[i].x+(t%m)*(a[i].c==1?1:-1);
        if(a[i].y<=0)a[i].y+=m;
        if(a[i].y>m)a[i].y-=m;
        if(a[i].c==2)cnt_l++;
    }
    sort(a,a+n,cmp);
    ll shift=2*n-2*cnt_l;shift%=n;
    shift*=t/m;shift%=n;t%=m;
    for(int i=0;i<n;i++)tmp[(i+shift)%n]=a[i].id;
    for(int i=0;i<n;i++)a[i].id=tmp[i];
    
    for(int i=0;i<n;i++)b[i]={a[i].y,i};
    sort(b,b+n);
    
    ll hits[2]={};
    for(int q=0;q<2;q++)
        for(int i=0;i<n;i++)
            if(a[i].c!=a[b[q].second].c)
            {
                ll p=b[q].second;
                ll l=a[p].x,r=a[p].y;
                ld pos1=((ld)a[p].x+a[i].x)/2,pos2=pos1+(ld)m/2;
                if(pos2>m)pos2-=m;
                if(l<=r && a[p].c==1)hits[q]+=(l<pos1 && pos1<r)+(l<pos2 && pos2<r);
                if(l<=r && a[p].c==2)hits[q]+=(pos1<l || r<pos1)+(pos2<l || r<pos2);
                if(r<l && a[p].c==2)hits[q]+=(r<pos1 && pos1<l)+(r<pos2 && pos2<l);
                if(r<l && a[p].c==1)hits[q]+=(pos1<r || l<pos1)+(pos2<r || l<pos2);
            }
    ll id1=(b[0].second+hits[0]*(a[b[0].second].c==1?1:-1)+5*n)%n,id2=(b[1].second+hits[1]*(a[b[1].second].c==1?1:-1)+5*n)%n;
    for(int i=id1,j=0;j<n;i++,i%=n,j++)
        ans[a[i].id]=b[(j+(b[0].first==b[1].first && (id2+1)%n==id1))%n].first;
    for(int i=0;i<n;i++)cout<<ans[i]%m<<endl;
    return 0;
}




Measured memory_bytes: 12288