n,k = list(map(int,input().split()))

a = list(map(int,input().split()))

dic = {}

for key, a in zip(list(range(1, n+1)), a):

    dic[key] = a

 

log = [-1]*(n+1)

next = dic[1]

step = 1

log[next] = step

k -= 1

while k:

    next = dic[next]

    step += 1

    k -= 1

    if log[next] != -1:

        k %= log[next] - step

    else:

        log[next] = step

print(next)
n,k = list(map(int,input().split()))



a = [0]

a.extend(list(map(int,input().split())))

l = [None]*(n+1)



now = 1

step = 0

l[now] = 0

while k:

    now = a[now]

    step += 1

    k -= 1

    if l[now] is not None:

        looplen = (step - l[now])

        k = k%looplen

    else:

        l[now] = step

print(now)
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
dic = {}
for key, a in zip(list(range(1, n + 1)), a):
    dic[key] = a
log = [-1] * (n + 1)
next = dic[1]
step = 1
log[next] = step
k -= 1
while k:
    next = dic[next]
    step += 1
    k -= 1
    if log[next] != -1:
        k %= log[next] - step
    else:
        log[next] = step
print(next)

n, k = list(map(int, input().split()))
a = [0]
a.extend(list(map(int, input().split())))
l = [None] * (n + 1)
now = 1
step = 0
l[now] = 0
while k:
    now = a[now]
    step += 1
    k -= 1
    if l[now] is not None:
        looplen = step - l[now]
        k = k % looplen
    else:
        l[now] = step
print(now)

-a = list(map(int, input().split())) -dic = {} -for key, a in zip(list(range(1, n + 1)), a): -    dic[key] = a -log = [-1] * (n + 1) -next = dic[1] -step = 1 -log[next] = step -k -= 1 +a = [0] +a.extend(list(map(int, input().split()))) +l = [None] * (n + 1) +now = 1 +step = 0 +l[now] = 0 -    next = dic[next] +    now = a[now] -    if log[next] != -1: -        k %= log[next] - step +    if l[now] is not None: +        looplen = step - l[now] +        k = k % looplen -        log[next] = step -print(next) +        l[now] = step +print(now)