Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

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

city = 1
route = []
cnt = [0] * n
route.append(1)


while True:
    city = roads[city-1] 
    cnt[city-1] += 1
    if cnt[city-1] == 2:
        st = route.index(city)
        length = len(route) - st
        break
    route.append(city)


if k <= len(route):
    print(route[k])

elif length >= 1:
    amari = (k+1-st) % length
    if amari  == 0:
        print(route[-1])
    else:
        print(route[amari+st-1])

Fixed submission:
n, k = map(int, input().split())

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

city = 1
route = []
cnt = [0] * n
cnt[0] += 1
route.append(1)


while True:
    city = roads[city-1] 
    cnt[city-1] += 1
    if cnt[city-1] == 2:
        st = route.index(city)
        length = len(route) - st
        break
    route.append(city)


if k < len(route):
    print(route[k])

else:
    amari = (k+1-st) % length
    if amari  == 0:
        print(route[-1])
    else:
        print(route[amari+st-1])

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

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

city = 1
route = []
cnt = [0] * n
cnt[0] += 1
route.append(1)


while True:
    city = roads[city-1] 
    cnt[city-1] += 1
    if cnt[city-1] == 2:
        st = route.index(city)
        length = len(route) - st
        break
    route.append(city)


if k <= len(route):
    print(route[k])

elif length >= 1:
    amari = (k+1-st) % length
    if amari  == 0:
        print(route[-1])
    else:
        print(route[amari+st-1])

Fixed submission:
n, k = map(int, input().split())

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

city = 1
route = []
cnt = [0] * n
cnt[0] += 1
route.append(1)


while True:
    city = roads[city-1] 
    cnt[city-1] += 1
    if cnt[city-1] == 2:
        st = route.index(city)
        length = len(route) - st
        break
    route.append(city)


if k < len(route):
    print(route[k])

else:
    amari = (k+1-st) % length
    if amari  == 0:
        print(route[-1])
    else:
        print(route[amari+st-1])

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

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

city = 1
route = []
cnt = [0] * n
cnt[0] += 1
route.append(0)


while True:
    city = roads[city-1] 
    cnt[city-1] += 1
    if cnt[city-1] == 2:
        st = route.index(city)
        length = len(route) - st
        break
    route.append(city)

if k <= len(route):
    print(route[k])

elif length >= 1:
    amari = (k+1-st) % length
    if amari  == 0:
        print(route[-1])
    else:
        print(route[amari+st-1])

Fixed submission:
n, k = map(int, input().split())

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

city = 1
route = []
cnt = [0] * n
cnt[0] += 1
route.append(1)


while True:
    city = roads[city-1] 
    cnt[city-1] += 1
    if cnt[city-1] == 2:
        st = route.index(city)
        length = len(route) - st
        break
    route.append(city)


if k < len(route):
    print(route[k])

else:
    amari = (k+1-st) % length
    if amari  == 0:
        print(route[-1])
    else:
        print(route[amari+st-1])

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

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

city = 1
route = []
cnt = [0] * n
route.append(0)


while True:
    city = roads[city-1] 
    cnt[city-1] += 1
    if cnt[city-1] == 2:
        st = route.index(city)
        length = len(route) - st
        break
    route.append(city)

if k <= len(route):
    print(route[k])

elif length >= 1:
    amari = (k+1-st) % length
    if amari  == 0:
        print(route[-1])
    else:
        print(route[amari+st-1])

else:
    print(1)

Fixed submission:
n, k = map(int, input().split())

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

city = 1
route = []
cnt = [0] * n
cnt[0] += 1
route.append(1)


while True:
    city = roads[city-1] 
    cnt[city-1] += 1
    if cnt[city-1] == 2:
        st = route.index(city)
        length = len(route) - st
        break
    route.append(city)


if k < len(route):
    print(route[k])

else:
    amari = (k+1-st) % length
    if amari  == 0:
        print(route[-1])
    else:
        print(route[amari+st-1])

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

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

city = 1
route = []
cnt = [0] * n
route.append(0)


while True:
    city = roads[city-1] 
    cnt[city-1] += 1
    if cnt[city-1] == 2:
        st = route.index(city)
        length = len(route) - st
        break
    route.append(city)

if k <= len(route):
    print(route[k])

else:
    amari = (k+1-st) % length
    if amari  == 0:
        print(route[-1])
    else:
        print(route[amari+st-1])

Fixed submission:
n, k = map(int, input().split())

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

city = 1
route = []
cnt = [0] * n
cnt[0] += 1
route.append(1)


while True:
    city = roads[city-1] 
    cnt[city-1] += 1
    if cnt[city-1] == 2:
        st = route.index(city)
        length = len(route) - st
        break
    route.append(city)


if k < len(route):
    print(route[k])

else:
    amari = (k+1-st) % length
    if amari  == 0:
        print(route[-1])
    else:
        print(route[amari+st-1])