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

L = list(map(int, input().strip().split()))

L = [v - 1 for v in L]



seen = set()

cur = 0

untillBackToIntersec = 0



while cur not in seen:

    seen.add(cur)

    untillBackToIntersec += 1

    cur = L[cur]



intersec = cur

cur = 0

beforeLoop = 0



while cur != intersec:

    cur = L[cur]

    beforeLoop += 1

if k<=beforeLoop:

    proceed=k

else:

    loopSize = untillBackToIntersec - beforeLoop

    proceed=(k - beforeLoop) % (loopSize) + beforeLoop

ans = 0



for _ in range(proceed):

    ans = L[ans]



print((ans + 1))
n, k = list(map(int, input().strip().split()))

L = list(map(int, input().strip().split()))

L = [v - 1 for v in L]

 

seen = set()

intersec = 0

route=[]

while intersec not in seen:

    seen.add(intersec)

    route.append(intersec)

    intersec = L[intersec]



intersecInd = route.index(intersec)



if k<=intersecInd:

    ans=route[k]

else:

    loopSize = len(route) - intersecInd

    ans = route[(k - intersecInd) % (loopSize) + intersecInd]

 

print((ans + 1))
n, k = list(map(int, input().strip().split()))
L = list(map(int, input().strip().split()))
L = [v - 1 for v in L]
seen = set()
cur = 0
untillBackToIntersec = 0
while cur not in seen:
    seen.add(cur)
    untillBackToIntersec += 1
    cur = L[cur]
intersec = cur
cur = 0
beforeLoop = 0
while cur != intersec:
    cur = L[cur]
    beforeLoop += 1
if k <= beforeLoop:
    proceed = k
else:
    loopSize = untillBackToIntersec - beforeLoop
    proceed = (k - beforeLoop) % (loopSize) + beforeLoop
ans = 0
for _ in range(proceed):
    ans = L[ans]
print((ans + 1))

n, k = list(map(int, input().strip().split()))
L = list(map(int, input().strip().split()))
L = [v - 1 for v in L]
seen = set()
intersec = 0
route = []
while intersec not in seen:
    seen.add(intersec)
    route.append(intersec)
    intersec = L[intersec]
intersecInd = route.index(intersec)
if k <= intersecInd:
    ans = route[k]
else:
    loopSize = len(route) - intersecInd
    ans = route[(k - intersecInd) % (loopSize) + intersecInd]
print((ans + 1))

-cur = 0 -untillBackToIntersec = 0 -while cur not in seen: -    seen.add(cur) -    untillBackToIntersec += 1 -    cur = L[cur] -intersec = cur -cur = 0 -beforeLoop = 0 -while cur != intersec: -    cur = L[cur] -    beforeLoop += 1 -if k <= beforeLoop: -    proceed = k +intersec = 0 +route = [] +while intersec not in seen: +    seen.add(intersec) +    route.append(intersec) +    intersec = L[intersec] +intersecInd = route.index(intersec) +if k <= intersecInd: +    ans = route[k] -    loopSize = untillBackToIntersec - beforeLoop -    proceed = (k - beforeLoop) % (loopSize) + beforeLoop -ans = 0 -for _ in range(proceed): -    ans = L[ans] +    loopSize = len(route) - intersecInd +    ans = route[(k - intersecInd) % (loopSize) + intersecInd]