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

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

visited = [-1]*(N+1)

path = []

at = 1

count = 0

while True:

    if visited[at] != -1:

        loop = count-visited[at]

        if K < count: # (K-visited[at])//loopが1以上であることを保証

            print((path[K])) # 条件 K < visited[at]なら、(K-visited[at])//loopが0以上であることを保証。どっちでもよさそう。

        else:

            print((path[(K-visited[at])%loop+visited[at]]))

        break

    visited[at] = count

    count += 1

    path.append(at)

    at = A[at-1]
n, k = list(map(int, input().split()))

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

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

p = []

a = 1

c = 0

while 1:

    if v[a] != -1:

        l = c-v[a]

        if k < c:

            print((p[k]))

        else:

            print((p[(k-v[a])%l+v[a]]))

        break

    v[a] = c

    c += 1

    p.append(a)

    a = q[a-1]
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
visited = [-1] * (N + 1)
path = []
at = 1
count = 0
while True:
    if visited[at] != -1:
        loop = count - visited[at]
        if K < count:  # (K-visited[at])//loopが1以上であることを保証
            print(
                (path[K])
            )  # 条件 K < visited[at]なら、(K-visited[at])//loopが0以上であることを保証。どっちでもよさそう。
        else:
            print((path[(K - visited[at]) % loop + visited[at]]))
        break
    visited[at] = count
    count += 1
    path.append(at)
    at = A[at - 1]

n, k = list(map(int, input().split()))
q = list(map(int, input().split()))
v = [-1] * (n + 1)
p = []
a = 1
c = 0
while 1:
    if v[a] != -1:
        l = c - v[a]
        if k < c:
            print((p[k]))
        else:
            print((p[(k - v[a]) % l + v[a]]))
        break
    v[a] = c
    c += 1
    p.append(a)
    a = q[a - 1]

-N, K = list(map(int, input().split())) -A = list(map(int, input().split())) -visited = [-1] * (N + 1) -path = [] -at = 1 -count = 0 -while True: -    if visited[at] != -1: -        loop = count - visited[at] -        if K < count:  # (K-visited[at])//loopが1以上であることを保証 -            print( -                (path[K]) -            )  # 条件 K < visited[at]なら、(K-visited[at])//loopが0以上であることを保証。どっちでもよさそう。 +n, k = list(map(int, input().split())) +q = list(map(int, input().split())) +v = [-1] * (n + 1) +p = [] +a = 1 +c = 0 +while 1: +    if v[a] != -1: +        l = c - v[a] +        if k < c: +            print((p[k])) -            print((path[(K - visited[at]) % loop + visited[at]])) +            print((p[(k - v[a]) % l + v[a]])) -    visited[at] = count -    count += 1 -    path.append(at) -    at = A[at - 1] +    v[a] = c +    c += 1 +    p.append(a) +    a = q[a - 1]