N, K = map(int, input().split())
A = list(map(lambda a: int(a) - 1, input().split()))

now = 0
for d in range(64):
    if ((1 << d) & K) > 0:
        now = A[now]
    A = [A[a] for a in A]
print(now + 1)

01db57071caf93b3303349e2af06703037981989
<mask token>

<mask token>
for d in range(64):
    if 1 << d & K > 0:
        now = A[now]
    A = [A[a] for a in A]
print(now + 1)

N, K = map(int, input().split())
A = list(map(lambda a: int(a) - 1, input().split()))
now = 0
for d in range(64):
    if 1 << d & K > 0:
        now = A[now]
    A = [A[a] for a in A]
print(now + 1)

N, K = map(int, input().split())
A = list(map(lambda a: int(a) - 1, input().split()))

now = 0
for d in range(64):
    if ((1 << d) & K) > 0:
        now = A[now]
    A = [A[a] for a in A]
print(now + 1)
