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

a = [int(i) for i in input().split()]

s = []

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

c, l = 1, 0

v = 1

while (ord[v] == -1):

    ord[v] = len(s)

    s.append(v)

    v = a[v-1]

    

c = len(s) - ord[v]

l = ord[v]

print((s[k] if (k < l) else s[l + (k - l) % c]))
n, k = list(map(int, input().split()))

a = [int(i) for i in input().split()]

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

s = []

v = 1

c, l = 1, 0

while ord[v] == -1:

    ord[v] = len(s)

    s.append(v)

    v = a[v - 1]

c = len(s) - ord[v]

l  = ord[v]

print((s[k] if k < l else s[l + (k - l) % c]))
n, k = list(map(int, input().split()))
a = [int(i) for i in input().split()]
s = []
ord = [-1] * (n + 1)
c, l = 1, 0
v = 1
while ord[v] == -1:
    ord[v] = len(s)
    s.append(v)
    v = a[v - 1]
c = len(s) - ord[v]
l = ord[v]
print((s[k] if (k < l) else s[l + (k - l) % c]))

n, k = list(map(int, input().split()))
a = [int(i) for i in input().split()]
ord = [-1] * (n + 1)
s = []
v = 1
c, l = 1, 0
while ord[v] == -1:
    ord[v] = len(s)
    s.append(v)
    v = a[v - 1]
c = len(s) - ord[v]
l = ord[v]
print((s[k] if k < l else s[l + (k - l) % c]))

+ord = [-1] * (n + 1) -ord = [-1] * (n + 1) +v = 1 -v = 1 -print((s[k] if (k < l) else s[l + (k - l) % c])) +print((s[k] if k < l else s[l + (k - l) % c]))