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

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



pre = 0

index = [-1]*N

path_cnt = 0

for i in range(N):

    if index[pre] >= 0:

        break

    else:

        index[pre] = i

        path_cnt += 1

    pre = A[pre]



loops = path_cnt - index[pre]

one = path_cnt - loops

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()]]



index = [-1]*N

pre, path_cnt = 0, 0

for i in range(N):

    if index[pre] >= 0: break

    else:

        index[pre] = i

        path_cnt += 1

    pre = A[pre]



loops = path_cnt - index[pre]

one = index[pre]

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()]]
pre = 0
index = [-1] * N
path_cnt = 0
for i in range(N):
    if index[pre] >= 0:
        break
    else:
        index[pre] = i
        path_cnt += 1
    pre = A[pre]
loops = path_cnt - index[pre]
one = path_cnt - loops
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()]]
index = [-1] * N
pre, path_cnt = 0, 0
for i in range(N):
    if index[pre] >= 0:
        break
    else:
        index[pre] = i
        path_cnt += 1
    pre = A[pre]
loops = path_cnt - index[pre]
one = index[pre]
k = max(0, K - one) % loops + min(K, one)
pre = 0
for _ in range(k):
    pre = A[pre]
print((pre + 1))

-pre = 0 -path_cnt = 0 +pre, path_cnt = 0, 0 -one = path_cnt - loops +one = index[pre]