You are given a circle with a circumference of L. Each point on the circumference has a coordinate value representing the arc length from a reference point clockwise. There are N ants on the circumference, numbered 1 through N in increasing coordinate order. Each ant starts walking in a given direction and may change direction if it collides with another ant. Find the position of each ant after T seconds. Constraints: N (number of ants) ≤ 10^5, L (circumference length) ≤ 10^9, T (time) ≤ 10^9, 0 ≤ X1 < X2 < ... < XN ≤ L - 1, 1 ≤ Wi (direction) ≤ 2. Input format: N L T, followed by N lines of X and W values. Output: N lines containing the final coordinates of each ant after T seconds. Example input and output are provided.

# Buggy version:
n,l,t=map(int,input().split())
data=[0]*n
s=0
for i in range(n):
  x,w=map(int,input().split())
  if w==1:
    data[i]=(x+t)%l
    s+=(x+t)//l
  else:
    data[i]==(x-t)%l
    s+=(x-t)//l
data.sort()
res=s%n
data=data[res:]+data[:res]
for i in data:
  print(i)

# Fixed version:
n,l,t=map(int,input().split())
data=[]
s=0
for i in range(n):
  x,w=map(int,input().split())
  if w==1:
    data.append((x+t)%l)
    s+=(x+t)//l
  else:
    data.append((x-t)%l)
    s+=(x-t)//l
data.sort()
res=s%n
data=data[res:]+data[:res]
for i in data:
  print(i)

# Buggy version:
n, l, t = map(int, input().split())

arr = []
for i in range(n):
    x, w = map(int, input().split())

    if w == 1:
        arr.append((x+t) % l)
        s += (x+t) // l
    else: # W == 2:
        arr.append((x-t) % l)
        s += (x-t) // l

arr.sort()
s %= n
arr = arr[s:] + arr[:s]
print(*[i for i in arr], sep='\n')

# Fixed version:
n, l, t = map(int,input().split())

c = []
s = 0

for i in range(n):
    x, w = map(int,input().split())
    if w == 1:
        c.append((x+t)%l)
        s += (x+t)//l
    else: # w == 2
        c.append((x-t)%l)
        s += (x-t)//l

c.sort()
s %= n
c = c[s:] + c[:s]
print(*[i for i in c], sep='\n')

# Buggy version:
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, L, T = map(int, readline().split())
    position = []
    #0をL-1からーに時計回りに超える場合は+1
    #0からL-1に反時計回りに超える場合は-1
    count = 0
    for i in range(N):
        x,w = map(int, readline().split())
        if w==1:
            count += (x+T)//L
            position.append((x+T)%L)
        else:
            if x-T<0:
                count += (x-T+1)//L
            position.append((x-T)%L)
    position.sort()
    if count>=0:
        ans = position[count:] + position[:count]
    print(ans)


if __name__ == '__main__':
    main()

# Fixed version:
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, L, T = map(int, readline().split())
    position = []
    #0をL-1からーに時計回りに超える場合は+1
    #0からL-1に反時計回りに超える場合は-1
    count = 0
    for i in range(N):
        x,w = map(int, readline().split())
        if w==1:
            count += (x+T)//L
            position.append((x+T)%L)
        else:
            if x-T<0:
                count += (x-T)//L
            position.append((x-T)%L)
    position.sort()
    count %= N
    ans = position[count:] + position[:count]
    for i in range(N):
        print(ans[i])


if __name__ == '__main__':
    main()

# Buggy version:
n, l, t = map(int,input().split())

c = []
s = 0

for i in range(n):
    x, w = map(int,input().split())
    if w == 1:
        c.append((x+t)%l)
        s += (x+t)//l
    else: # w == 2:
        c.append((x-t)%l)
        s += (x-t)//l

c.sort()
s %= n
c = c[s:] + c[:s]
print(c)

print([i for i in c], sep='\n')

# Fixed version:
n,l,t = map(int,input().split())
c = []
s = 0
for i in range(n):
  x,w = map(int,input().split())
  if w == 1:
    c.append((x+t)%l)
    s += (x+t)//l
  else:
    c.append((x-t)%l)
    s += (x-t)//l
    
c.sort()
s %= n
c = c[s:] + c[:s]
print(*[i for i in c], sep='\n')

# Buggy version:
N, L, T=map(int, input().split())
XW=[list(map(int, input().split())) for _ in range(N)]
X_=[(XW[i][0]+T)%L if XW[i][1]==1 else (XW[i][0]-T)%L for i in range(N)]
X_.sort()
A0_=(XW[0][0]+T)%L if XW[0][1]==1 else (XW[0][0]-T)%L
P0_=X_.index(A0_)
if P0_>0:
    X_=X_[P0_:]+X_[:P0_]
    
if XW[0][1]==1:
    C0_=round(sum([(T-(XW[i][0]-XW[0][0])/2)//(L/2)+1 if XW[i][1]!=1 and (XW[i][0]-XW[0][0])/2<=T else 0 for i in range(1, N)])%N)
else:
    C0_=round(N-sum([(T-(XW[0][0]+L-XW[i][0])/2)//(L/2)+1 if XW[i][1]!=2 and (XW[0][0]+L-XW[i][0])/2<=T else 0 for i in range(1, N)])%N)
    
if X_[0]==X_[1] and XW[0][1]==1:
  C0_=round((C0_-1)%N)
'''
if C0_>0:
  X_=X_[N-C0_:]+X_[:N-C0_]
'''
print(*X_, sep='\n')

# Fixed version:
N, L, T=map(int, input().split())
XW=[list(map(int, input().split())) for _ in range(N)]
X_=[(XW[i][0]+T)%L if XW[i][1]==1 else (XW[i][0]-T)%L for i in range(N)]
X_.sort()
A0_=(XW[0][0]+T)%L if XW[0][1]==1 else (XW[0][0]-T)%L
P0_=X_.index(A0_)
if P0_>0:
    X_=X_[P0_:]+X_[:P0_]
    
if XW[0][1]==1:
    C0_=round(sum([(T-(XW[i][0]-XW[0][0])/2)//(L/2)+1 if XW[i][1]!=1 and (XW[i][0]-XW[0][0])/2<=T else 0 for i in range(1, N)])%N)
else:
    C0_=round(N-sum([(T-(XW[0][0]+L-XW[i][0])/2)//(L/2)+1 if XW[i][1]!=2 and (XW[0][0]+L-XW[i][0])/2<=T else 0 for i in range(1, N)])%N)
    
if N>1 and X_[0]==X_[1] and XW[0][1]==1:
  C0_=round((C0_-1)%N)

if C0_>0:
  X_=X_[N-C0_:]+X_[:N-C0_]

print(*X_, sep='\n')

# Buggy version:
n,l,t=map(int,input().split())
inf=[]
s=0
for _ in range(n)
x,y=map(int,input().split())
   if y==1:
       x+=t
   else:
       x-=t
    inf.append(x%l)
    s+=x//l
inf.sort()
s%n
for i in range(n):
    print(inf[(i+p)%n])

# Fixed version:
n,l,t=map(int,input().split())
inf=[]
s=0
for _ in range(n):
   x,y=map(int,input().split())
   if y==1:
       x+=t
   else:
       x-=t
   inf.append(x%l)
   s+=x//l
inf.sort()
for i in range(n):
    print(inf[(i+s)%n])

# Buggy version:
from collections import deque

n, l, t = map(int, input().split())
ants = [list(map(int, input().split())) for i in range(n)]

ants_t = [0]*n
count = 0
for i in range(n):
    ant = ants[i]
    if ant[1] == 1:
        c, ant_t = divmod(t + ant[0], l)
    else:
        c, ant_t = divmod(-t + ant[0], l)
    ants_t.append(ant_t)
    count += c
# print(ants_t, count)
ants_d = deque(sorted(ants_t))
# print(ants_d)

ants_d.rotate(-count)
# print(ants_d)
for ant in ants_d:
    print( (ant) % l )


# Fixed version:
from collections import deque

n, l, t = map(int, input().split())
ants = [list(map(int, input().split())) for i in range(n)]
# print(ants)

ants_t = []
count = 0
for ant in ants:
    ant_t = ant
    if ant[1] == 1:
        c, ant_t[0] = divmod(t + ant[0], l)
        # count += c
    else:
        c, ant_t[0] = divmod(-t + ant[0], l)
        # count -= c
    ants_t.append(ant_t)
    count += c
# print(ants_t, count)
ants_d = deque(sorted(ants_t))
# print(ants_d)

# if ants_d[0][1] == 1:
#     ants_d.rotate(count)
# else:
#     ants_d.rotate(-count)
ants_d.rotate(-count)
# print(ants_d)
for ant in ants_d:
    print( (ant[0]) % l )

# Buggy version:
N, L, T = map(int, input().split())
x = ["" for i in range(N)]
w = ["" for i in range(N)]
for i in range(N):
    x[i], w[i] = map(int, input().split())

y = [[i, ""] for i in range(N)]
for i in range(N):
    y[i][1] = (x[i] + (-1)**(w[i]+1)*T) % L

count = 0
for i in range(N):
    if w[0] < w[i]:
        count += (2 * T + L - x[i] + x[0]) // L
    elif w[0] > w[i]:
        count += (2 * T + x[i] - x[0]) // L

if w[0] == 1:
    num = count % N
else:
    num = -count % N

y.sort(key=lambda x: (x[1], -x[0]))

for i in range(N):
    if y[i][0] == 0:
        index = i
        break

for i in range(N):
    print(y[(index-num+i) % N][1])


# Fixed version:
N, L, T = map(int, input().split())
x = ["" for i in range(N)]
w = ["" for i in range(N)]
for i in range(N):
    x[i], w[i] = map(int, input().split())

y = [[i, ""] for i in range(N)]
for i in range(N):
    y[i][1] = (x[i] + (-1)**(w[i]+1)*T) % L

count = 0
for i in range(N):
    if w[0] < w[i]:
        count += (2 * T + L - x[i] + x[0]) // L
    elif w[0] > w[i]:
        count += (2 * T + x[i] - x[0]) // L

if w[0] == 1:
    num = count % N
else:
    num = -count % N

if w[0] == 1:
    y.sort(key=lambda x: (x[1], -x[0]))
else:
    y.sort(key=lambda x: (x[1], x[0]))

for i in range(N):
    if y[i][0] == 0:
        index = i
        break

for i in range(N):
    print(y[(index-num+i) % N][1])

# Buggy version:
n,l,t =  map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
las = [0]*n
for i in range(n):
  las[i] = (x[i][0]+(t if x[i][1]==1 else -t))%l
han = []
for i in range(1,n):
  if x[i][1] != x[0][1]:
    if x[0][1] ==1:
      han.append(x[i][1]-x[0][0])
    else:
      han.append(l-x[i][0]+x[0][0])
su = 0
t*=2
su += len(han)*(t//l)
t%=l
for i in han:
  if t> i:
    su+=1
su%=(n)
ii = las[0]
las.sort()
basyo = las.index(ii)
for i in range(basyo,n):
  if las[basyo] == las[i]:
    basyo+=1
    break
las.extend(las)
ans = [0]*n
z = 0
for i in range(basyo,basyo+n):
  ans[(su+z)%n] = las[i]
  z += 1
for i in ans:
  print(i)

# Fixed version:
n,l,t =  map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
las = [0]*n
for i in range(n):
  las[i] = (x[i][0]+(t if x[i][1]==1 else -t))%l
han = []
for i in range(1,n):
  if x[i][1] != x[0][1]:
    if x[0][1] ==1:
      han.append(x[i][0]-x[0][0])
    else:
      han.append(l-x[i][0]+x[0][0])
su = 0
t*=2
su += (len(han))*(t//l)
t%=l
for i in han:
  if t> i:
    su+=1
if x[0][1] == 2:
  su=(-su)%n
else:
  su%=(n)
ii = las[0]
las.sort()
basyo = las.index(ii)
for i in range(basyo+1,n):
  if las[basyo] == las[i]:
    if x[0][1] == 2:
      basyo+=1
  break
las.extend(las)
ans = [0]*n
z = 0
for i in range(basyo,basyo+n):
  ans[(su+z)%n] = las[i]
  z += 1
for i in ans:
  print(i)

# Buggy version:
n,l,t=map(int,input().split())
a,cs=[0]*n,0
for i in range(n):
	x,y=map(int,input().split())
	x+=(t if y==1 else -t)
	cs=(cs+x//l)%n
	x%=l
	a[i]=x
a.sort()
print('\n'.join([str(a[(i+cs)%n]) fori in range(n)]))


# Fixed version:
n,l,t=map(int,input().split())
a,cs=[0]*n,0
for i in range(n):
	x,y=map(int,input().split())
	x+=(t if y==1 else -t)
	cs=(cs+x//l)%n
	x%=l
	if x<0:
		x+=l
		cs-=1
	a[i]=x
a.sort()
print('\n'.join([str(a[(i+cs+n)%n]) for i in range(n)]))

# Buggy version:
import math
temp=input().split()
N=int(temp[0])
L=int(temp[1])
T=int(temp[2])
XW=[[int(j) for j in input().split()] for i in range(N)]
count=0
for i in range(N):
	if XW[i][1]==1:
		XW[i][0]+=T
	else:
		XW[i][0]-=T
	# count+=math.floor(XW[i][0]/L)

if XW[0][1]==1:
	for i in range(1,N):
		if XW[i][0]<XW[0][0]:
			count+=int((XW[0][0]-XW[i][0])/L)+1
else:
	for i in range(1,N):
		if XW[i][0]>XW[0][0]:
			count+=int((XW[i][0]-XW[0][0])/L)+1

#print(count)
#print(len())
newX=[]
for i in range(N):
	newX.append(XW[i][0]%L)
newX.sort()
#print(newX)
for i in range(N):
	print(newX[(i+count)%N]%L)


# Fixed version:
import math
temp=input().split()
N=int(temp[0])
L=int(temp[1])
T=int(temp[2])
XW=[[int(j) for j in input().split()] for i in range(N)]
count=0
for i in range(N):
	if XW[i][1]==1:
		XW[i][0]+=T
	else:
		XW[i][0]-=T
	count+=math.floor(XW[i][0]/L)
newX=[]
for i in range(N):
	newX.append(XW[i][0]%L)
newX.sort()
#print(newX)
for i in range(N):
	print(newX[(i+count)%N]%L)

# Buggy version:
N, L, T = list(map(int, input().split()))

X = []
W = []
X_after = []
for _ in range(N):
    x, w = list(map(int, input().split()))
    if w == 1:
        x_a = (x + T) % L
    else:
        x_a = (x - T) % L
        x_a = x_a if x_a >= 0 else L + x_a
    X.append(x)
    W.append(w)
    X_after.append(x_a)

n_colide = 0
for i in range(1, N):
    if W[0] == 1 and W[i] == 2:
        dist = X[i] - X[0]
        n_colide += 2 * (T - (dist / 2)) // L + 1
    elif W[0] == 2 and W[i] == 1:
        dist = (L + X[0]) - X[i]
        n_colide += 2 * (T - (dist / 2)) // L + 1

if W[0] == 1:
    num_a0 = n_colide % N
else:
    num_a0 = N - (n_colide % N)

num_a0 = int(num_a0)

x_a0 = X_after[0]
X_after = sorted(X_after)
i = X_after.index(x_a0)
if X_after.count(x_a0) == 2:
    i += 1
X_after = X_after[i-num_a0:] + X_after[:i-num_a0]

for x_a in X_after:
    print(x_a)


# Fixed version:
N, L, T = list(map(int, input().split()))

X = []
W = []
X_after = []
for _ in range(N):
    x, w = list(map(int, input().split()))
    if w == 1:
        x_a = (x + T) % L
    else:
        x_a = (x - T) % L
        x_a = x_a if x_a >= 0 else L + x_a
    X.append(x)
    W.append(w)
    X_after.append(x_a)

n_colide = 0
for i in range(1, N):
    if W[0] == 1 and W[i] == 2:
        dist = X[i] - X[0]
        n_colide += 2 * (T - (dist / 2)) // L + 1
    elif W[0] == 2 and W[i] == 1:
        dist = (L + X[0]) - X[i]
        n_colide += 2 * (T - (dist / 2)) // L + 1

if W[0] == 1:
    num_a0 = n_colide % N
else:
    num_a0 = N - (n_colide % N)

num_a0 = int(num_a0)

x_a0 = X_after[0]
X_after = sorted(X_after)
i = X_after.index(x_a0)
if W[0] == 1 and X_after.count(x_a0) == 2:
    i += 1
X_after = X_after[i-num_a0:] + X_after[:i-num_a0]

for x_a in X_after:
    print(x_a)

# Buggy version:
N, L, T = list(map(int, input().split(" ")))

# N,L,T = 3,10,6
# a = [1,2,3]
# b = [2,1,1]

a = []
b = []
for i in range(N):
    an, ve = map(int, input().split(" "))
    a.append(an)
    b.append(ve)

crash = 0

for i in range(1, N):
    if b[0] != b[i]:
        if b[0] == 1:
            crash += (T - ((a[i] - a[0]) / 2)) // (L / 2) + 1
        else:
            crash += (T - (L - (a[i] - a[0])) / 2) // (L / 2) + 1

for i in range(N):
    if b[i] == 1:
        a[i] += T
    else:
        a[i] -= T
    a[i] %= L


if b[0] == 1:
    where = int(crash) % N
else:
    where = int(-crash) % N

nowplace = a[where]
a.sort()

if b[0] == 1:
	if crash % 2 == 1:
		where0 = min([i for i in range(N) if a[i] == nowplace])
	else:
		where0 = max([i for i in range(N) if a[i] == nowplace])		
else:
	if crash % 2 == 1:
		where0 = max([i for i in range(N) if a[i] == nowplace])
	else:
		where0 = min([i for i in range(N) if a[i] == nowplace])

where0 = (where0 - crash) % N

res = a[where0:] + a[:where0]
res = map(str, res)

for i in res:
    print(i)


# Fixed version:
N, L, T = list(map(int, input().split(" ")))

# N,L,T = 3,10,6
# a = [1,2,3]
# b = [2,1,1]

a = []
b = []
for i in range(N):
    an, ve = map(int, input().split(" "))
    a.append(an)
    b.append(ve)

crash = 0

for i in range(1, N):
    if b[0] != b[i]:
        if b[0] == 1:
            crash += (T - ((a[i] - a[0]) / 2)) // (L / 2) + 1
        else:
            crash += (T - (L - (a[i] - a[0])) / 2) // (L / 2) + 1

for i in range(N):
    if b[i] == 1:
        a[i] += T
    else:
        a[i] -= T
    a[i] %= L


if b[0] == 1:
    where = int(crash) % N
else:
    where = int(-crash) % N

nowplace = a[0]

a.sort()

if b[0] == 1:
	where0 = max([i for i in range(N) if a[i] == nowplace])
else:
	where0 = min([i for i in range(N) if a[i] == nowplace])

where0 = (where0 - where) % N

res = a[where0:] + a[:where0]
res = map(str, res)

for i in res:
    print(i)

# Buggy version:
# C
import numpy as np
N, L, T = map(int, input().split())
X = list()
W = list()
positions = list()
for _ in range(N):
    x, w = map(int, input().split())
    X.append(x)
    W.append(w)
    if w == 1:
        positions.append((x + T) % L)
    else:
        positions.append((x - T) % L)

# find which is the position
cnt_conf = 0
for i in range(N):
    if W[i] != W[0]:
        cnt_conf += (2*T - (X[i] - X[0])) // L + 1
n0 = cnt_conf % N
if W[0] == 1:
    p0 = (X[0] + T) % L
else:
    p0 = (X[0] - T) % L

positions.sort()

# find index
if W[0] == 1:
    num = min([n for n in range(N) if positions[n]==p0])
else:
    num = max([n for n in range(N) if positions[n]==p0])

for i in range(N):
    print(positions[(num - n0 + i) % N])

# Fixed version:
# C
N, L, T = map(int, input().split())
X = list()
W = list()
positions = list()
for _ in range(N):
    x, w = map(int, input().split())
    X.append(x)
    W.append(w)
    if w == 1:
        positions.append((x + T) % L)
    else:
        positions.append((x - T) % L)

# find which is the position
cnt_conf = 0
if W[0] == 1:
    for i in range(N):
        if W[i] != W[0]:
            cnt_conf += (2*T - (X[i] - X[0])) // L + 1
    n0 = cnt_conf % N
    p0 = (X[0] + T) % L
else:
    for i in range(N):
        if W[i] != W[0]:
            cnt_conf += (2*T - (X[0] + L - X[i])) // L + 1
    n0 = -cnt_conf % N
    p0 = (X[0] - T) % L

positions.sort()

# find index
if W[0] == 1:
    num = max([n for n in range(N) if positions[n]==p0])
else:
    num = min([n for n in range(N) if positions[n]==p0])

for i in range(N):
    print(positions[(num - n0 + i) % N])

# Buggy version:
import math
temp=input().split()
N=int(temp[0])
L=int(temp[1])
T=int(temp[2])
XW=[[int(j) for j in input().split()] for i in range(N)]
count=0
for i in range(N):
	if XW[i][1]==1:
		XW[i][0]+=T
	else:
		XW[i][0]-=T
	count+=math.floor(XW[i][0]/L)
"""
if XW[0][1]==1:
	for i in range(1,N):
		if XW[i][0]<XW[0][0]:
			count+=int((XW[0][0]-XW[i][0])/L)+1
else:
	for i in range(1,N):
		if XW[i][0]>XW[0][0]:
			count+=int((XW[i][0]-XW[0][0])/L)+1
"""
#print(count)
#print(len())
newX=[]
for i in range(N):
	newX.append(XW[i][0]%L)
newX.sort()
print(newX)
for i in range(N):
	print(newX[(i+count)%N]%L)

# Fixed version:
import math
temp=input().split()
N=int(temp[0])
L=int(temp[1])
T=int(temp[2])
XW=[[int(j) for j in input().split()] for i in range(N)]
count=0
for i in range(N):
	if XW[i][1]==1:
		XW[i][0]+=T
	else:
		XW[i][0]-=T
	count+=math.floor(XW[i][0]/L)
"""
if XW[0][1]==1:
	for i in range(1,N):
		if XW[i][0]<XW[0][0]:
			count+=int((XW[0][0]-XW[i][0])/L)+1
else:
	for i in range(1,N):
		if XW[i][0]>XW[0][0]:
			count+=int((XW[i][0]-XW[0][0])/L)+1
"""
#print(count)
#print(len())
newX=[]
for i in range(N):
	newX.append(XW[i][0]%L)
newX.sort()
#print(newX)
for i in range(N):
	print(newX[(i+count)%N]%L)