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

A = [*[int(x)-1 for x in input().split()]]



cnt = [0]*N

pre = 0

for _ in range(N*2):

    cnt[pre] += 1

    now = A[pre]

    pre = now



one = 0

loops = 0

for c in cnt:

    if c == 1: one += 1

    elif c > 1: loops += 1



k = max(0, K-one) % loops + min(K, one)



pre = 0

for _ in range(k):

    now = A[pre]

    pre = now



ans = pre + 1

print(ans)

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

A = [*[int(x)-1 for x in input().split()]]



cnt, pre = [0]*N, 0

for _ in range(N*2):

    cnt[pre] += 1

    pre = A[pre]



one, loops = 0, 0

for c in cnt:

    if c == 1: one += 1

    elif c > 1: loops += 1



k = max(0, K-one) % loops + min(K, one)



pre = 0

for _ in range(k): pre = A[pre]

print((pre + 1))

N, K = list(map(int, input().split()))
A = [*[int(x) - 1 for x in input().split()]]
cnt = [0] * N
pre = 0
for _ in range(N * 2):
    cnt[pre] += 1
    now = A[pre]
    pre = now
one = 0
loops = 0
for c in cnt:
    if c == 1:
        one += 1
    elif c > 1:
        loops += 1
k = max(0, K - one) % loops + min(K, one)
pre = 0
for _ in range(k):
    now = A[pre]
    pre = now
ans = pre + 1
print(ans)

N, K = list(map(int, input().split()))
A = [*[int(x) - 1 for x in input().split()]]
cnt, pre = [0] * N, 0
for _ in range(N * 2):
    cnt[pre] += 1
    pre = A[pre]
one, loops = 0, 0
for c in cnt:
    if c == 1:
        one += 1
    elif c > 1:
        loops += 1
k = max(0, K - one) % loops + min(K, one)
pre = 0
for _ in range(k):
    pre = A[pre]
print((pre + 1))

-cnt = [0] * N -pre = 0 +cnt, pre = [0] * N, 0 -    now = A[pre] -    pre = now -one = 0 -loops = 0 +    pre = A[pre] +one, loops = 0, 0 -    now = A[pre] -    pre = now -ans = pre + 1 -print(ans) +    pre = A[pre] +print((pre + 1))