Harryxun/stf_run huggingface dataset:
import sys

sys.setrecursionlimit(10**10)

n, u, v = map(int, input().split())

# nodeの値を-1しておく
u = u-1
v = v-1

# Making Adjacency list
Adj_dict = {}
for i in range(n):
    new = {i: []}
    Adj_dict.update(new)

for _ in range(n-1):
    a, b = map(int, input().split())
    Adj_dict[a-1].append(b-1)
    Adj_dict[b-1].append(a-1)


def tree_distance(Adj_dict, start, Visited, distance, Dist_list):
    
    # 現在いる位置を Visited = True に変更する
    Visited[start] = True

    # 該当するnodeの距離を記録して、distanceを1加算する
    Dist_list[start] = distance
    distance += 1

    # 訪れていないnodeに対して、dfs
    for node in Adj_dict[start]:
        if Visited[node] == False:
            tree_distance(Adj_dict, node, Visited, distance, Dist_list)
    
    return


Dist_list = [0 for _ in range(n)]
Visited = [False for _ in range(n)]
distance = 0
tree_distance(Adj_dict, u, Visited, distance, Dist_list)
Taka = Dist_list

Dist_list = [0 for _ in range(n)]
Visited = [False for _ in range(n)]
distance = 0
tree_distance(Adj_dict, v, Visited, distance, Dist_list)
Aoki = Dist_list

Taka_num = 0
node = 0
for i in range(n):
    if Aoki[i] >= Taka[i]:
        if Taka[i] >= Taka_num:
            Taka_num = Taka[i]
            node = i

# TakahashiはTaka_numのnodeへ逃げる
ans = Aoki[node] -1

print(ans)

### FIXED CODE ###

import sys

sys.setrecursionlimit(200000)

n, u, v = map(int, input().split())

# nodeの値を-1しておく
u = u-1
v = v-1

# Making Adjacency list
Adj_dict = {}
for i in range(n):
    new = {i: []}
    Adj_dict.update(new)

for _ in range(n-1):
    a, b = map(int, input().split())
    Adj_dict[a-1].append(b-1)
    Adj_dict[b-1].append(a-1)

def tree_distance(Adj_dict, start, Visited, distance, Dist_list):
    
    # 現在いる位置を Visited = True に変更する
    Visited[start] = True

    # 該当するnodeの距離を記録して、distanceを1加算する
    Dist_list[start] = distance
    distance += 1

    # 訪れていないnodeに対して、dfs
    for node in Adj_dict[start]:
        if Visited[node] == False:
            tree_distance(Adj_dict, node, Visited, distance, Dist_list)
    
    return


Dist_list = [0 for _ in range(n)]
Visited = [False for _ in range(n)]
distance = 0
tree_distance(Adj_dict, u, Visited, distance, Dist_list)
Taka = Dist_list

Dist_list = [0 for _ in range(n)]
Visited = [False for _ in range(n)]
distance = 0
tree_distance(Adj_dict, v, Visited, distance, Dist_list)
Aoki = Dist_list

Taka_num = 0
node = 0
ans = 0
for i in range(n):
    if Aoki[i] > Taka[i]:
        ans = max(ans, Aoki[i]-1)


print(ans)
import sys

n = int(sys.stdin.readline().strip())
nums = list(map(int, sys.stdin.readline().strip().split()))

d = dict()
for one in nums:
    if one in d:
        d[one] += 1
    else:
        d[one] = 1
history = dict()
history[0] = 1
history[1] = 1
history[2] = 2
def stepMulti(v):
    if v < 1:
        return 1
    if v not in history:
        history[v]  = v * stepMulti(v-1)
    return history[v]

def C(a,b):
    return stepMulti(a) // (stepMulti(a-b) * stepMulti(b))

res_history = dict()

for one in nums:
    if one in res_history:
        print(res_history[one])
    else:
        d[one] -= 1
        res = 0
        for k,v in d.items():
            if v==2:
                res += 1
            elif v > 2:
                res += C(v, 2)
        print (res)
        d[one] += 1
        res_history[one] = res


### FIXED CODE ###

import sys

n = int(sys.stdin.readline().strip())
nums = list(map(int, sys.stdin.readline().strip().split()))
# appear times
d = dict()
for one in nums:
    if one in d:
        d[one] += 1
    else:
        d[one] = 1

def C(a):
    return (a*(a-1)//2 )

accum = 0
for k, v in d.items():
    accum += C(v)

res_history = dict()

for one in nums:
    if one in res_history:
        print(res_history[one])
    else:
        if d[one] == 1:
            print(accum)
        else:
            res = accum 
            delta = C(d[one]) - C(d[one] - 1)
            res -= delta
            res_history[one] = res
            print(res)
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def combinations_with_replacement_count(n, r):
    return combinations_count(n + r - 1, r)
nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]
fact = list()
i = 2
while m != 1:
    if m % i == 0:
        m = m // i
        fact.append(i)
    else:
        i += 1
j = 2
ans = 1
while j <= fact[-1]:
    ans = ans * combinations_with_replacement_count(n, fact.count(j))
    j += 1
print(ans % (10 ** 9 + 7))


### FIXED CODE ###

import math


def combinations_with_replacement_count(n, r):
    return math.factorial(n + r - 1) // (math.factorial(n - 1) * math.factorial(r))


nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]
fact = {}
i = 2
while i * i <= m:
    while m % i == 0:
        m = m // i
        if i in fact:
            fact[i] += 1
        else:
            fact[i] = 1
    i += 1
if m > 1:
    fact[m] = 1
j = 2
ans = 1
for k in fact:
    ans = ans * combinations_with_replacement_count(n, fact[k])
print(ans % (10 ** 9 + 7))
a, b = map(int,input().split())
if a*b % 2 =1:
  print("Odd")
else:
  print("Even")

### FIXED CODE ###

a, b = map(int,input().split())
if a*b % 2 == 1:
  print("Odd")
else:
  print("Even")
import math

N = int(input())
A = list(map(int,input().split(" ")))

gcd = math.gcd

l = [0]*N
r = [0]*N

l[0] = A[0]
r[-1] = A[-1]

for x in range(1,N):
    l[x] = gcd(A[x],l[x-1])

for x in range(N-2,-1,-1):
    r[x] = gcd(A[x],r[x+1])

l.insert(0,0)
l.append(0)
r.insert(0,0)
r.append(0)

o = []

for x in range(N):
    o.append(gcd(l[x-1],r[x+1]))

print(max(o))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split(" ")))

def gcd(m,n):
    while n != 0:
        a = n
        n = m % n
        m = a
    return m

l = [0]*N
r = [0]*N

l[0] = A[0]
r[-1] = A[-1]

for x in range(1,N):
    y = N - 1 - x
    l[x] = gcd(A[x],l[x-1])
    r[y] = gcd(A[y],r[y+1])

l.insert(0,0)
l.append(0)
r.insert(0,0)
r.append(0)

o = 1

for x in range(N):
    o = max(o,gcd(l[x],r[x+2]))

print(o)
s = '' while True: try: s += input().lower() except EOFError: break for c in 'abcdefghijklmnopqrstuvwxyz': print('{} : {}'.format(c, s.count(c))) 


### FIXED CODE ###

import sys
S= sys.stdin.read()
print('a : '+str(S.count('a')+S.count('A')))
print('b : '+str(S.count('b')+S.count('B')))
print('c : '+str(S.count('c')+S.count('C')))
print('d : '+str(S.count('d')+S.count('D')))
print('e : '+str(S.count('e')+S.count('E')))
print('f : '+str(S.count('f')+S.count('F')))
print('g : '+str(S.count('g')+S.count('G')))
print('h : '+str(S.count('h')+S.count('H')))
print('i : '+str(S.count('i')+S.count('I')))
print('j : '+str(S.count('j')+S.count('J')))
print('k : '+str(S.count('k')+S.count('K')))
print('l : '+str(S.count('l')+S.count('L')))
print('m : '+str(S.count('m')+S.count('M')))
print('n : '+str(S.count('n')+S.count('N')))
print('o : '+str(S.count('o')+S.count('O')))
print('p : '+str(S.count('p')+S.count('P')))
print('q : '+str(S.count('q')+S.count('Q')))
print('r : '+str(S.count('r')+S.count('R')))
print('s : '+str(S.count('s')+S.count('S')))
print('t : '+str(S.count('t')+S.count('T')))
print('u : '+str(S.count('u')+S.count('U')))
print('v : '+str(S.count('v')+S.count('V')))
print('w : '+str(S.count('w')+S.count('W')))
print('x : '+str(S.count('x')+S.count('X')))
print('y : '+str(S.count('y')+S.count('Y')))
print('z : '+str(S.count('z')+S.count('Z')))
n, *L = map(int, open(0).read().split())
mod = 10 ** 9 + 7
con = [[] for _ in range(n + 1)]
sz = [1] * (n + 1)
par = [0] * (n + 1)

for s, t in zip(*[iter(L)] * 2):
	con[s] += t,
	con[t] += s,


def prepare(m, mod=10 ** 9 + 7):
	fac = [1] * (m + 1)
	inv = [1] * (m + 1)
	for i in range(1, m + 1):
		fac[i] = fac[i - 1] * i % mod
	inv[-1] = pow(fac[-1], mod - 2, mod)
	for i in range(m - 1, -1, -1):
		inv[i] = inv[i + 1] * (i + 1) % mod
	return fac, inv


fac, inv = prepare(n)


def dfs1(cur, pre):
	par[cur] = pre
	for nxt in con[cur]:
		if nxt != pre:
			dfs1(nxt, cur)
			sz[cur] += sz[nxt]
			dp1[cur] *= dp1[nxt] * inv[sz[nxt]] % mod
			dp1[cur] %= mod
	dp1[cur] *= fac[sz[cur] - 1]
	dp1[cur] %= mod


def dfs2(cur, pre):
	dp2[cur] *= dp1[cur] * inv[sz[cur] - 1] % mod
	dp2[cur] %= mod
	dp2[cur] *= fac[n - 1]
	dp2[cur] %= mod
	for nxt in con[cur]:
		if nxt != pre:
			dp2[nxt] = fac[sz[nxt]] * pow(n - sz[nxt], mod - 2, mod) * pow(dp1[nxt], mod - 2, mod) * dp2[cur] * inv[n - 1] % mod
			dfs2(nxt, cur)


dp1 = [1] * (n + 1)
dfs1(1, 0)
dp2 = [1] * (n + 1)
dfs2(1, 0)

print(*dp2[1:], sep="\n")


### FIXED CODE ###

import sys
sys.setrecursionlimit(1234567890)

n, *L = map(int, open(0).read().split())
mod = 10 ** 9 + 7
con = [[] for _ in range(n + 1)]
sz = [1] * (n + 1)
par = [0] * (n + 1)

for s, t in zip(*[iter(L)] * 2):
	con[s] += t,
	con[t] += s,


def prepare(m, mod=10 ** 9 + 7):
	fac = [1] * (m + 1)
	inv = [1] * (m + 1)
	for i in range(1, m + 1):
		fac[i] = fac[i - 1] * i % mod
	inv[-1] = pow(fac[-1], mod - 2, mod)
	for i in range(m - 1, -1, -1):
		inv[i] = inv[i + 1] * (i + 1) % mod
	return fac, inv


fac, inv = prepare(n)


def dfs1(cur, pre):
	par[cur] = pre
	for nxt in con[cur]:
		if nxt != pre:
			dfs1(nxt, cur)
			sz[cur] += sz[nxt]
			dp1[cur] *= dp1[nxt] * inv[sz[nxt]] % mod
			dp1[cur] %= mod
	dp1[cur] *= fac[sz[cur] - 1]
	dp1[cur] %= mod


def dfs2(cur, pre):
	dp2[cur] *= dp1[cur] * inv[sz[cur] - 1] % mod
	dp2[cur] %= mod
	dp2[cur] *= fac[n - 1]
	dp2[cur] %= mod
	for nxt in con[cur]:
		if nxt != pre:
			dp2[nxt] = fac[sz[nxt]] * pow(n - sz[nxt], mod - 2, mod) * pow(dp1[nxt], mod - 2, mod) * dp2[cur] * inv[n - 1] % mod
			dfs2(nxt, cur)


dp1 = [1] * (n + 1)
dfs1(1, 0)
dp2 = [1] * (n + 1)
dfs2(1, 0)

print(*dp2[1:], sep="\n")
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
                a[j][k]=0

for i in range(3):
    flag=True
    for j in range(3):
        if a[i][j]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()

for i in range(3):
    flag=True
    for j in range(3):
        if a[j][i]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()

for i in range(3):
    flag=True
    if a[i][i]!=0:
        flag=False
if flag:
    print("Yes")
    exit()

for i in range(3):
    if a[i][3-i]!=0:
        print("No")
        exit()
print("Yes")
exit()

### FIXED CODE ###

a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
                a[j][k]=0
 
for i in range(3):
    flag=True
    for j in range(3):
        if a[i][j]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()
 
for i in range(3):
    flag=True
    for j in range(3):
        if a[j][i]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()

flag=True
for i in range(3):
    if a[i][i]!=0:
        flag=False
if flag:
    print("Yes")
    exit()
 
for i in range(3):
    if a[i][2-i]!=0:
        print("No")
        exit()
print("Yes")
exit()
N = list(input())
print(len(N)*9+N[0]-1)

### FIXED CODE ###

N = list(input())

flg = 0
for i in range(1,len(N)):
    if N[i]=="9":
        continue
    else:
        flg = 1
        break

if flg:
    print((len(N)-1)*9+int(N[0])-1)
else:
    print((len(N)-1)*9+int(N[0]))
s=input()
t=''
a=1
for i in len(s)-1:
  if s[i]!=s[i+1]:
    a+=1
print(a)

### FIXED CODE ###

_=input()
s=input()
t=''
a=1
for i in range(len(s)-1):
  if s[i]!=s[i+1]:
    a+=1
print(a)
s = input()

ss = ""
for i in range(len(S)):
  if s[i] == "1"
  	ss += "9"	
  else:
    ss += "1"
    
print(ss)

### FIXED CODE ###

s = input()
 
ss = ""
for i in s:
  if i == "1":
  	ss += "9"	
  else:
    ss += "1"
    
print(ss)
#素因数分解
def Prime_Factorization(N):
    if N<0:
        R=[[-1,1]]
    else:
        R=[]

    N=abs(N)
    k=2
    while k*k<=N:
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])
        k+=1

    if N!=1:
        R.append([N,1])
    if not R:
        R.append([N,1])

    return R
#================================================
from math import gcd
N=int(input())
A=list(map(int,input().split()))

#Pairwise?
P=set()
F=True
for a in A:
    K=Prime_Factorization(a)
    for (p,_) in K:
        if p in P:
            F=False
            break
        else:
            P.add(p)

    if not F:
        break

if F:
    print(1/0)
    print("pairwise coprime")
    exit()

#Setwise?
g=A[0]
for a in A:
    g=gcd(g,a)
    if g==1:
        break

if g==1:
    print("setwise coprime")
else:
    print("not coprime")


### FIXED CODE ###

#素因数分解
def Prime_Factorization(N):
    if N<0:
        R=[[-1,1]]
    else:
        R=[]

    N=abs(N)
    k=2
    while k*k<=N:
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])
        k+=1

    if N!=1:
        R.append([N,1])
    if not R:
        R.append([N,1])

    return R
#================================================
from math import gcd
N=int(input())
A=list(map(int,input().split()))

#Pairwise?
P=set()
F=True
for a in A:
    K=Prime_Factorization(a)
    for (p,_) in K:
        if p in P and p!=1:
            F=False
            break
        else:
            P.add(p)

    if not F:
        break

if F:
    print("pairwise coprime")
    exit()

#Setwise?
g=A[0]
for a in A:
    g=gcd(g,a)

if g==1:
    print("setwise coprime")
else:
    print("not coprime")
n=int(input())
t=list(map(int,input().split()))
m=int(input())
drink=[]
all=sum(t)
for i in range(m):
  drink.append(list(map(int,input().split())))
for j in range(m):
  if drink[j][0]<=n:
    print(all-t[drink[j][0]]+drink[j][1])
  else:
    print(all)


### FIXED CODE ###

n=int(input())
t=list(map(int,input().split()))
m=int(input())
drink=[]
all=sum(t)
for i in range(m):
  drink.append(list(map(int,input().split())))
for j in range(m):
  if drink[j][0]<=n:
    print(all-t[drink[j][0]-1]+drink[j][1])
  else:
    print(all)
l, r, d = map(int, input())
print(r // d - (l - 1) // d)

### FIXED CODE ###

l, r, d = map(int, input().split())
print(r // d - (l - 1) // d)
n = int(input())
p = list(map(int, input().split()))
a = p

ans = []
for i in range(1,n+1):
  ans.append(i)

  

for i in range(n):
  for j in range(n):
    a[i] = p[j]
    a[j] = p[i]
    if a == ans:
      print('YES')
      exit()
    else:
      a = p
    print(p)    
      
      
      
    
print('NO')

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
cnt = 0
  
for i in range(n-1):
  if h[i] - h[i+1] >= 2:
    print('No')
    exit()
  elif h[i] - h[i+1] == 1:
    cnt += -1
  elif h[i] - h[i+1] <= -1:
    cnt = 0
  if cnt == -2:
    print('No')
    exit()
    
    
print('Yes')
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
n=ii()
a,b,c=[],[],[]

for i in range(n):
    x,y,z=mii()
    a.append(x)
    b.append(y)
    c.append(z)

dp=[[0]*n for i in range(3)]
dp[0][0],dp[1][0],dp[2][0]=a[0],b[0],c[0]
for i in range(1,n):
    for j in [0,1,2]:
        if j==0:dp[0][i]=max(dp[1][i-1]+a[i],dp[2][i-1]+a[i])
        elif j==1:dp[1][i]=max(dp[0][i-1]+b[i],dp[2][i-1]+b[i])
        elif j==2:dp[2][i]=max(dp[1][i-1]+c[i],dp[0][i-1]+c[i])

print(max(dp[0][-1],dp[1][-1],dp[2][-1]))



### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #整数1つinput
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii())
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #文字列1つinput
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

n = ii()
arr = limii()
dp = [0]*n
chk=True
cnt=1
while chk:
    if cnt==1:
        dp[cnt] = abs(arr[cnt]-arr[cnt-1])
    else:
        dp[cnt] = min(abs(arr[cnt]-arr[cnt-1])+dp[cnt-1],abs(arr[cnt]-arr[cnt-2])+dp[cnt-2])

    if cnt==n-1:
        chk=False
    cnt+=1
print(dp[-1])
Old = int(input())
if Old == 1:
    print('Hello World')
else:
    A, B = map(int, input().split())
    print(A + B)

### FIXED CODE ###

Old = int(input())
if Old == 1:
    print('Hello World')
else:
    A = int(input())
    B = int(input())
    print(A + B)
import math
k=int(input())
sum=0

for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      sum+=math.gcd(a,b,c)

      
print(sum)

### FIXED CODE ###

from math import gcd
k=int(input())
cnt=0
for i in range(1,k+1):
  for j in range(1,k+1):
    a=gcd(i,j)
    for k in range(1,k+1):
      cnt+=gcd(a,k)
print(cnt)
# -*- coding: utf-8 -*-
      
      
    b, c = map(int, input().split())
     
    s=0.5*(b+c)
     
    d = int(s)
    
    if s-d > 0:
      v=int(d+1)
    else :
      v=int(d)
    print(v)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Nov  3 09:19:07 2018

@author: sk
"""

     
      
b, c = map(int, input().split())
     
s=0.5*(b+c)
     
d = int(s)
    
if s-d > 0:
    v=int(d+1)
else :
    v=int(d)
print(v)
h, w = map(int, input().split())
dots = []
for i in range(h):
  print(dots[i])
  print(dots[i])
    

### FIXED CODE ###

h, w = map(int, input().split())
dots = []
for i in range(h):
  dots.append(str(input()))
  print(dots[i])
  print(dots[i])
import math
l,r=map(int,input().split())

t=r
c=0
while(t!=0):
    c+=1
    t//=2
LIST=[0]*c


l=l-1

t1=math.ceil(l/2)
t2=math.ceil(r/2)
LIST[-1]=((t2-t1)%2)*(2**(0))

for i in range(2,c+1):
    k=(l-(l//2**i)*(2**i))+1
    t1=max(k-((2**i)//2),0)

    k=(r-(r//2**i)*(2**i))+1
    t2=max(k-((2**i)//2),0)
 
    LIST[-i]=((t2-t1)%2)*(2**(i-1))

print(sum(LIST))

### FIXED CODE ###

import math
l,r=map(int,input().split())

t=r
c=0
while(t!=0):
    c+=1
    t//=2
LIST=[0]*c

if(c==0):
    print(0)
    exit()

l=l-1

t1=math.ceil(l/2)
t2=math.ceil(r/2)
LIST[-1]=((t2-t1)%2)*(2**(0))

for i in range(2,c+1):
    k=(l-(l//2**i)*(2**i))+1
    t1=max(k-((2**i)//2),0)

    k=(r-(r//2**i)*(2**i))+1
    t2=max(k-((2**i)//2),0)
 
    LIST[-i]=((t2-t1)%2)*(2**(i-1))

print(sum(LIST))
N = int(input())

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x,y))
    
    
import itertools
import collections

ans_list = []
for v in itertools.permutations(XY):
    count_list = []
    for (x0, y0), (x1,y1) in zip(v[1:], v[:-1]):
        count_list.append((x1-x0, y1-y0))
    ans_list.append(max(collections.Counter(count_list).values()))
    
ans = N-max(ans_list)
print(ans)
    

    



### FIXED CODE ###

N = int(input())

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x,y))
    
from collections import defaultdict

dd = defaultdict(lambda:defaultdict(bool))

X = sorted(XY)

for x,y in XY:
    dd[x][y] = True

max_count = 0
for i, (x0, y0) in enumerate(X):
    for x1, y1 in X[i+1:]:
        diff_x, diff_y = (x1-x0, y1-y0)
        counter = 0
        for x, y in X:
            if dd[x+diff_x][y+diff_y]:
                counter += 1
        max_count = max(max_count, counter)
#print(max_count)

ans = N - max_count
print(ans)
def gcd(a, b):
    if a < b:
        a, b = b, a
    while b != 0:
        temp = a % b
        a = b
        b = temp
    return a
def blackbord(n,a):
    return max(list(hcf(a[i],j) for i in range(len(a)) for j in a[0:i] + a[i + 1:]))
n = int(input())
a=list(map(int, input().split()))
print(blackbord(n,a))

### FIXED CODE ###

def biscuit(a,b,t):
    i = 1
    while i*a<=t:
        i = i+1
    return b*(i-1)
    
a,b,t = map(int, input().split())
print(biscuit(a,b,t))
n,k=list(map(int,input().split()))
A=list(map(int,input().split()))
start,steps=1,0
root=dict()

while start not in root and steps < k:
  steps+=1
  root[start]=steps
  start=A[start-1]

if steps == k:
  print(start+1)
else:
  pa = steps-root[start]
  s=root[start]
  ans=(k-steps)%pa
  root={v: k for k, v in root.items()}
  print(root[s+ans])

### FIXED CODE ###

n,k=list(map(int,input().split()))
A=list(map(int,input().split()))
start,steps=1,0
root=dict()

while start not in root and steps < k:
  root[start]=steps
  steps+=1
  start=A[start-1]

if steps == k:
  print(start)
else:
  pa = steps-root[start]
  ans= root[start] + (k-steps)%pa
  root={v: k for k, v in root.items()}
  print(root[ans])
def function(arg1, arg2):
    N,K = map(int, arg1.split())
    teleportes = list(map(int, arg2.split()))
    checked = [0] * len(teleportes) # 訪れた街にチェック

    i = 0
    c = 1
    while True :
        nextTerminal = teleportes[i] - 1
        if checked[i] == 0:
            checked[i] = c # 何番目に訪れたか
            i = nextTerminal
            c += 1
        else:
            loops = c - checked[i] # 以前訪れてから何回旅したか
            
            break
    
    if K <= i:
        goal = teleportes[K]
    else:
        k = 0
        nextTerminal = 0
        while k in range((K-i)%loops + i):
            nextTerminal = teleportes[nextTerminal] - 1
            goal = nextTerminal + 1
            k+=1
    return str(goal)

if __name__ == '__main__':
    print(function(input(),input()))


### FIXED CODE ###

def function():
    _N,K = map(int, input().split())
    teleportes = list(map(int, input().split()))

    # ループを見つける
    i,count = 0,0
    visited = [-1] * len(teleportes) # 訪れた街にチェック
    while True :
        if visited[i] == -1: # 最初に訪れた
            visited[i] = count # 何番目に訪れたかを記録
            i = teleportes[i] - 1
            count += 1
        else:
            loops = count - visited[i] # 以前訪れてから何回旅したか
            break
    
    if K <= visited[i]:
        i = 0
    else:
        K -= visited[i]
        K %= loops
    for _k in range(K):
        i = teleportes[i] - 1
    print(i+1)

if __name__ == '__main__':
    function()
a,b = input()

### FIXED CODE ###

a,b = map(int,input().split())
if a*b%2 == 0:
  print("Even")
else:
  print("Odd")