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

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

g=[1]

h={1}

for i in range(N-1):

  x=t[g[i]-1]

  g.append(x)

  if x in h:

    break

  h.add(x)

if K>len(g):

  a=g.index(g[-1])

  b=len(g)-a-1

  K=(K-a)%b+a

print((g[K]))
N,K=list(map(int,input().split()))

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

g=[1]

for i in range(N-1):

  g.append(t[g[i]-1])

if K>len(g):

  a=g.index(g[-1])

  b=len(g)-a-1

  K=(K-a)%b+a

print((g[K]))
N, K = list(map(int, input().split()))
t = list(map(int, input().split()))
g = [1]
h = {1}
for i in range(N - 1):
    x = t[g[i] - 1]
    g.append(x)
    if x in h:
        break
    h.add(x)
if K > len(g):
    a = g.index(g[-1])
    b = len(g) - a - 1
    K = (K - a) % b + a
print((g[K]))

N, K = list(map(int, input().split()))
t = list(map(int, input().split()))
g = [1]
for i in range(N - 1):
    g.append(t[g[i] - 1])
if K > len(g):
    a = g.index(g[-1])
    b = len(g) - a - 1
    K = (K - a) % b + a
print((g[K]))

-h = {1} -    x = t[g[i] - 1] -    g.append(x) -    if x in h: -        break -    h.add(x) +    g.append(t[g[i] - 1])