Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int,input().split()))
move_list = list(map(int,input().split()))
 
  
test = 1
find_f = {}
for i in range(N):
  find_f[i+1]=[]
 
find_f[1].append(0)
for i in range(K):
  test = move_list[test-1]
  find_f[test].append(i+1)
  if len(find_f[test]) == 2 and find_f[test][1]-find_f[test][0]<=100000:
    state ,f = test, find_f[test]
    break
try:
  K = K-f[0]
  f = f[1]-f[0]
  remain = K%f

  for i in range(remain):
    state = move_list[state-1]

  print(state)
except:
  print(test)
#state = 1

Fixed submission:
N, K = list(map(int,input().split()))
move_list = list(map(int,input().split()))
 
  
test = 1
find_f = {}
for i in range(N):
  find_f[i+1]=[]
 
find_f[1].append(0)
for i in range(K):
  test = move_list[test-1]
  find_f[test].append(i+1)
  if len(find_f[test]) == 2 and find_f[test][1]-find_f[test][0]<=1000000:
    state ,f = test, find_f[test]
    break
try:
  K = K-f[0]
  f = f[1]-f[0]
  remain = K%f
  for i in range(remain):
    state = move_list[state-1]
 
  print(state)
except:
  print(test)
#state = 1

Buggy python submission (verdict: Runtime Error):
N, K = list(map(int,input().split()))
move_list = list(map(int,input().split()))
 
  
test = 1
find_f = {}
for i in range(N):
  find_f[i+1]=[]
 
find_f[1].append(0)
for i in range(K):
  test = move_list[test-1]
  find_f[test].append(i+1)
  if len(find_f[test]) == 2 and find_f[test][1]-find_f[test][0]<=1000:
    state ,f = test, find_f[test]
    break
  
K = K-f[0]
f = f[1]-f[0]
remain = K%f
 
for i in range(remain):
  state = move_list[state-1]
  
print(state)
#state = 1

Fixed submission:
N, K = list(map(int,input().split()))
move_list = list(map(int,input().split()))
 
  
test = 1
find_f = {}
for i in range(N):
  find_f[i+1]=[]
 
find_f[1].append(0)
for i in range(K):
  test = move_list[test-1]
  find_f[test].append(i+1)
  if len(find_f[test]) == 2 and find_f[test][1]-find_f[test][0]<=1000000:
    state ,f = test, find_f[test]
    break
try:
  K = K-f[0]
  f = f[1]-f[0]
  remain = K%f
  for i in range(remain):
    state = move_list[state-1]
 
  print(state)
except:
  print(test)
#state = 1

Buggy python submission (verdict: Runtime Error):
N, K = list(map(int,input().split()))
move_list = list(map(int,input().split()))
 
  
test = 1
find_f = {}
for i in range(N):
  find_f[i+1]=[]
 
find_f[1].append(0)
for i in range(K):
  test = move_list[test-1]
  find_f[test].append(i+1)
  if len(find_f[test]) == 2 and find_f[test][1]-find_f[test][0]<=100:
    state ,f = test, find_f[test]
    break
  
K = K-f[0]
f = f[1]-f[0]
remain = K%f
 
for i in range(remain):
  state = move_list[state-1]
  
print(state)
#state = 1

Fixed submission:
N, K = list(map(int,input().split()))
move_list = list(map(int,input().split()))
 
  
test = 1
find_f = {}
for i in range(N):
  find_f[i+1]=[]
 
find_f[1].append(0)
for i in range(K):
  test = move_list[test-1]
  find_f[test].append(i+1)
  if len(find_f[test]) == 2 and find_f[test][1]-find_f[test][0]<=1000000:
    state ,f = test, find_f[test]
    break
try:
  K = K-f[0]
  f = f[1]-f[0]
  remain = K%f
  for i in range(remain):
    state = move_list[state-1]
 
  print(state)
except:
  print(test)
#state = 1

Buggy python submission (verdict: Runtime Error):
N, K = list(map(int,input().split()))
move_list = list(map(int,input().split()))
 
  
test = 1
find_f = {}
for i in range(N):
  find_f[i+1]=[]
 
find_f[1].append(0)
for i in range(K):
  test = move_list[test-1]
  find_f[test].append(i+1)
  if len(find_f[test]) == 2 and find_f[test][1]-find_f[test][0]<=100000:
    state ,f = test, find_f[test]
    break
  
K = K-f[0]
f = f[1]-f[0]
remain = K%f
 
for i in range(remain):
  state = move_list[state-1]
  
print(state)
#state = 1

Fixed submission:
N, K = list(map(int,input().split()))
move_list = list(map(int,input().split()))
 
  
test = 1
find_f = {}
for i in range(N):
  find_f[i+1]=[]
 
find_f[1].append(0)
for i in range(K):
  test = move_list[test-1]
  find_f[test].append(i+1)
  if len(find_f[test]) == 2 and find_f[test][1]-find_f[test][0]<=1000000:
    state ,f = test, find_f[test]
    break
try:
  K = K-f[0]
  f = f[1]-f[0]
  remain = K%f
  for i in range(remain):
    state = move_list[state-1]
 
  print(state)
except:
  print(test)
#state = 1

Buggy python submission (verdict: Runtime Error):
N, K = list(map(int,input().split()))
move_list = list(map(int,input().split()))

  
test = 1
find_f = {}
for i in range(N):
  find_f[i+1]=[]

find_f[1].append(0)
for i in range(K):
  test = move_list[test-1]
  find_f[test].append(i+1)
  if len(find_f[test]) == 2:
    state ,f = test, find_f[test]
    break
  
K = K-f[0]
f = f[1]-f[0]
remain = K%f

for i in range(remain):
  state = move_list[state-1]
  
print(state)
#state = 1

#for i in range(K):
#  state = move_list[state][1]
  

Fixed submission:
N, K = list(map(int,input().split()))
move_list = list(map(int,input().split()))
 
  
test = 1
find_f = {}
for i in range(N):
  find_f[i+1]=[]
 
find_f[1].append(0)
for i in range(K):
  test = move_list[test-1]
  find_f[test].append(i+1)
  if len(find_f[test]) == 2 and find_f[test][1]-find_f[test][0]<=1000000:
    state ,f = test, find_f[test]
    break
try:
  K = K-f[0]
  f = f[1]-f[0]
  remain = K%f
  for i in range(remain):
    state = move_list[state-1]
 
  print(state)
except:
  print(test)
#state = 1