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

*l, = list(map(int,input().split()))

seenl = [1]

seen = {1}

d={}

for index,i in enumerate(l):

  d[index+1]=i

#print(d)

temp=1

for i in range(k):

  temp=d[temp]

  if temp in seen:

    #print('i=',i)

    #print('temp=',temp)

    lenloop = len(seenl)-seenl.index(temp)

    #print('lenloop=',lenloop)

    r = (k-i-1)%lenloop

    temp = seenl[seenl.index(temp):][r]

    break

  seenl.append(temp)

  seen.add(temp)

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

*l, = list(map(int,input().split()))

seenl = [1]

seen = {1}

temp=1

for i in range(k):

  temp=l[temp-1]

  if temp in seen:

    lenloop = len(seenl)-seenl.index(temp)

    r = (k-i-1)%lenloop

    temp = seenl[seenl.index(temp):][r]

    break

  seenl.append(temp)

  seen.add(temp)

print(temp)
n, k = list(map(int, input().split()))
(*l,) = list(map(int, input().split()))
seenl = [1]
seen = {1}
d = {}
for index, i in enumerate(l):
    d[index + 1] = i
# print(d)
temp = 1
for i in range(k):
    temp = d[temp]
    if temp in seen:
        # print('i=',i)
        # print('temp=',temp)
        lenloop = len(seenl) - seenl.index(temp)
        # print('lenloop=',lenloop)
        r = (k - i - 1) % lenloop
        temp = seenl[seenl.index(temp) :][r]
        break
    seenl.append(temp)
    seen.add(temp)
print(temp)

n, k = list(map(int, input().split()))
(*l,) = list(map(int, input().split()))
seenl = [1]
seen = {1}
temp = 1
for i in range(k):
    temp = l[temp - 1]
    if temp in seen:
        lenloop = len(seenl) - seenl.index(temp)
        r = (k - i - 1) % lenloop
        temp = seenl[seenl.index(temp) :][r]
        break
    seenl.append(temp)
    seen.add(temp)
print(temp)

-d = {} -for index, i in enumerate(l): -    d[index + 1] = i -# print(d) -    temp = d[temp] +    temp = l[temp - 1] -        # print('i=',i) -        # print('temp=',temp) -        # print('lenloop=',lenloop)