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

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

bit = k.bit_length()

table = [[0]*bit for _ in range(n)]

for i in range(n):

    table[i][0] = A[i]



for i in range(1, bit):

    for j in range(n):

        table[j][i] = table[table[j][i-1]][i-1]



ans = 0

for i in reversed(list(range(bit))):

    if (1 << i) <= k:

        k -= 1 << i

        ans = table[ans][i]

print((ans+1))

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

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

bit = k.bit_length()

table = [[0]*n for _ in range(bit)]

table[0] = A



for i in range(1, bit):

    for j in range(n):

        table[i][j] = table[i-1][table[i-1][j]]



ans = 0

for i in reversed(list(range(bit))):

    if (1 << i) <= k:

        k -= 1 << i

        ans = table[i][ans]

print((ans+1))
n, k = list(map(int, input().split()))
A = list([int(x) - 1 for x in input().split()])
bit = k.bit_length()
table = [[0] * bit for _ in range(n)]
for i in range(n):
    table[i][0] = A[i]
for i in range(1, bit):
    for j in range(n):
        table[j][i] = table[table[j][i - 1]][i - 1]
ans = 0
for i in reversed(list(range(bit))):
    if (1 << i) <= k:
        k -= 1 << i
        ans = table[ans][i]
print((ans + 1))

n, k = list(map(int, input().split()))
A = list([int(x) - 1 for x in input().split()])
bit = k.bit_length()
table = [[0] * n for _ in range(bit)]
table[0] = A
for i in range(1, bit):
    for j in range(n):
        table[i][j] = table[i - 1][table[i - 1][j]]
ans = 0
for i in reversed(list(range(bit))):
    if (1 << i) <= k:
        k -= 1 << i
        ans = table[i][ans]
print((ans + 1))

-table = [[0] * bit for _ in range(n)] -for i in range(n): -    table[i][0] = A[i] +table = [[0] * n for _ in range(bit)] +table[0] = A -        table[j][i] = table[table[j][i - 1]][i - 1] +        table[i][j] = table[i - 1][table[i - 1][j]] -        ans = table[ans][i] +        ans = table[i][ans]