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

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



move=[]

for i in range(0,N):

    move.append([])

    A[i]-=1

    move[i].append(A[i])





for j in range(1,64):

    for i in range(0,N):

        move[i].append(move[move[i][j-1]][j-1])

town=0

for i in range(0,64):

    if K%2==1:

        town=move[town][i]

    K//=2



print((town+1))

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

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



cycle=[]

for i in range(0,N):

    cycle.append(-1)

    A[i]-=1



count=0

cycle[0]=count

town=0

mod=0

while True:

    count+=1

    K-=1

    town=A[town]

    if K==0:

        mod=1

        break

    if cycle[town]==-1:

        cycle[town]=count

    else:

        mod=count-cycle[town]

        break



K%=mod

while K>0:

    town=A[town]

    K-=1



print((town+1))

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
move = []
for i in range(0, N):
    move.append([])
    A[i] -= 1
    move[i].append(A[i])
for j in range(1, 64):
    for i in range(0, N):
        move[i].append(move[move[i][j - 1]][j - 1])
town = 0
for i in range(0, 64):
    if K % 2 == 1:
        town = move[town][i]
    K //= 2
print((town + 1))

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
cycle = []
for i in range(0, N):
    cycle.append(-1)
    A[i] -= 1
count = 0
cycle[0] = count
town = 0
mod = 0
while True:
    count += 1
    K -= 1
    town = A[town]
    if K == 0:
        mod = 1
        break
    if cycle[town] == -1:
        cycle[town] = count
    else:
        mod = count - cycle[town]
        break
K %= mod
while K > 0:
    town = A[town]
    K -= 1
print((town + 1))

-move = [] +cycle = [] -    move.append([]) +    cycle.append(-1) -    move[i].append(A[i]) -for j in range(1, 64): -    for i in range(0, N): -        move[i].append(move[move[i][j - 1]][j - 1]) +count = 0 +cycle[0] = count -for i in range(0, 64): -    if K % 2 == 1: -        town = move[town][i] -    K //= 2 +mod = 0 +while True: +    count += 1 +    K -= 1 +    town = A[town] +    if K == 0: +        mod = 1 +        break +    if cycle[town] == -1: +        cycle[town] = count +    else: +        mod = count - cycle[town] +        break +K %= mod +while K > 0: +    town = A[town] +    K -= 1