from collections import deque



n, l, t = list(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 ))

from collections import deque



n, l, t = list(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[i] = 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 ))

from collections import deque

n, l, t = list(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))

from collections import deque

n, l, t = list(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[i] = 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))

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