N, K = list(map(int, input().split()))

*A, = list(map(int, input().split()))

A = [a-1 for a in A]



# Douling(ダブリング)

i = 1

to = [[a for a in A]]

while pow(2, i) < K:

    t = [to[i-1][to[i-1][j]] for j in range(N)]

    to.append(t)

    i += 1



i -= 1

ans = [i for i in range(N)]

while i >= 0:

    if K & (1 << i) > 0:

        for j in range(N):

            ans[j] = to[i][ans[j]]

    i -= 1

print((ans[0]+1))
N, K = list(map(int, input().split()))

*A, = list(map(int, input().split()))

A = [a-1 for a in A]



# Douling(ダブリング)

i = 1

to = [[a for a in A]]

while pow(2, i) < K:

    t = [to[i-1][to[i-1][j]] for j in range(N)]

    to.append(t)

    i += 1



i -= 1

ans = 0

while i >= 0:

    if K & (1 << i) > 0:

        ans = to[i][ans]

    i -= 1

print((ans+1))
N, K = list(map(int, input().split()))
(*A,) = list(map(int, input().split()))
A = [a - 1 for a in A]
# Douling(ダブリング)
i = 1
to = [[a for a in A]]
while pow(2, i) < K:
    t = [to[i - 1][to[i - 1][j]] for j in range(N)]
    to.append(t)
    i += 1
i -= 1
ans = [i for i in range(N)]
while i >= 0:
    if K & (1 << i) > 0:
        for j in range(N):
            ans[j] = to[i][ans[j]]
    i -= 1
print((ans[0] + 1))

N, K = list(map(int, input().split()))
(*A,) = list(map(int, input().split()))
A = [a - 1 for a in A]
# Douling(ダブリング)
i = 1
to = [[a for a in A]]
while pow(2, i) < K:
    t = [to[i - 1][to[i - 1][j]] for j in range(N)]
    to.append(t)
    i += 1
i -= 1
ans = 0
while i >= 0:
    if K & (1 << i) > 0:
        ans = to[i][ans]
    i -= 1
print((ans + 1))

-ans = [i for i in range(N)] +ans = 0 -        for j in range(N): -            ans[j] = to[i][ans[j]] +        ans = to[i][ans] -print((ans[0] + 1)) +print((ans + 1))