@staticmethod
def d():
    (n, m, d, *a) = map(int, sys.stdin.read().split())
    res = list(range(n))

    def swap(i, j):
        (res[i], res[j]) = (res[j], res[i])
    for i in a[::(- 1)]:
        swap((i - 1), i)
    group = ([None] * n)
    root = ([None] * n)
    index_in_group = ([None] * n)
    for i in range(n):
        if (root[i] is not None):
            continue
        group[i] = []
        j = i
        for cnt in range(1, (n + 1)):
            index_in_group[j] = (cnt - 1)
            group[i].append(j)
            j = res[j]
            root[j] = i
            if (j == i):
                break
    for i in range(n):
        g = group[root[i]]
        print((g[((index_in_group[i] + d) % len(g))] + 1))
@staticmethod
def d():
    (n, m, d, *a) = map(int, sys.stdin.read().split())
    res = list(range(n))

    def swap(i, j):
        (res[i], res[j]) = (res[j], res[i])
    for i in a[::(- 1)]:
        swap((i - 1), i)
    group = ([None] * n)
    root = ([None] * n)
    index_in_group = ([None] * n)
    for i in range(n):
        if (root[i] is not None):
            continue
        group[i] = []
        j = i
        for cnt in range(1, (n + 1)):
            index_in_group[j] = (cnt - 1)
            group[i].append(j)
            j = res[j]
            root[j] = i
            if (j == i):
                break
    for i in range(n):
        g = group[root[i]]
        print((g[((index_in_group[i] + d) % len(g))] + 1))