Harryxun/stf_run huggingface dataset:
n, m = list(map(int, input().split()))


connections = dict()
answer = {
    'true': 'POSSIBLE',
    'false': 'IMPOSSIBLE'
}


def add_to_set(a, b):
    if a in connections:
        connections[a].add(b)
    else:
        connections[a] = set([b])

    if b in connections:
        connections[b].add(a)
    else:
        connections[b] = set([a])


for i in range(m):
    a, b = list(map(int, input().split()))
    add_to_set(a, b)

island_1 = connections.get(1)
island_N = connections.get(n)

for e in island_1:
    if e in island_N:
        print(answer['true'])
    else:
        print(answer['false'])

### FIXED CODE ###

n, m = map(int, input().split())

is1 = [False] * (n + 1)
isN = [False] * (n + 1)

for i in range(m):
    a, b = map(int, input().split())
    if(a > b):
        a, b = b, a
    if(a == 1):
        is1[b] = True
    if(b == n):
        isN[a] = True

import sys

for i in range(2, n):
    if(is1[i] and isN[i]):
        print("POSSIBLE")
        sys.exit(0)

print("IMPOSSIBLE")
s = input()
print( s/3600, s%3600/3, s%3600%60, sep=":")

### FIXED CODE ###

S = int( input())
print( S//3600, S%3600//60, S%3600%60, sep=":")
a, b = map(int,input().split())

def lcm(a, b):
    y = a*b / math.gcd(a, b)
    return int(y)

print(lcm(a,b))

### FIXED CODE ###

from fractions import gcd
a, b = map(int,input().split())

def lcm(a, b):
  return a * b // gcd (a, b)

print(lcm(a, b))
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
for i in range(N):
    tmp = V[i]-C[i]
    if tmp > 0:
        ans += tmp
print(ans)




### FIXED CODE ###

N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(N):
    tmp = V[i]-C[i]
#     print(tmp)
    if tmp > 0:
        ans += tmp
#     print(ans)
print(ans)
N, M = map(int, input().split(' '))

height = list(map(int, input().split(' ')))
height_all = height

for i range(M):
  a, b = map(int, input().split(' '))
  if height[a - 1] == height[b - 1]:
    height_all.remove(height[a - 1])
  elif height[a - 1] > height[b - 1]:
    height_all.remove(height[b - 1])
  else:
    height_all.remove(height[a - 1])
print(len(height_all))

### FIXED CODE ###

import numpy as np
N, M = map(int, input().split(' '))

height = np.array(list(map(int, input().split(' '))))
height_all = np.array(list(height))

for i in range(M):
  a, b = map(int, input().split(' '))
  #print(a, b, height[a - 1], height[b - 1])
  if height[a - 1] > height[b - 1]:
    height_all[b - 1] = 0
  
  elif height[a - 1] == height[b - 1]:
    height_all[a - 1] = 0
    height_all[b - 1] = 0
    
  else:
    height_all[a - 1] = 0
    
  #print(height_all)
  
print(len(np.nonzero(height_all)[0]))
H,W,N = [int(input()) for i in range(3)]
o = 1
a = N / o
while a <= H or W:
  if H < W and a > W:
      o += 1
  else W < H and a > H:
      o += 1
print(o)    
    
    
    





	

  
  
  



### FIXED CODE ###

H,W,N = [int(input()) for i in range(3)]
for o in range(1,10000):
  if H <= W and N / o <= W:
    break
  elif H >= W and N / o <= H:
    break
print(o)
class MyClass():
    def main(self):
        self.n = input()
        self.A = map(int,raw_input().split())
        self.q = input()
        self.M = map(int,raw_input().split())
        
        W = map(self.solve,self.M)
        for w in W:
            print w

    def solve(self,m):
        w = self.rec(m,self.A)
        if w:
            return "yes"
        else:
            return "no"

    def rec(self,m,A):
        if len(A) == 1:
            r1 = False
        else:
            r1 = self.rec(m,A[1:])
        
        m_new = m - A[0]
        if m_new < 0:
            r2 = False
        elif m_new == 0:
            r2 = True
        elif m_new < min(A[1:]) or len(A) == 1:
            r2 = False
        else:
            r2 = self.rec(m_new,A[1:])
        
        if r1 or r2:
            return True
        else:
            return False
    
if __name__ == "__main__":
    MC = MyClass()
    MC.main()

### FIXED CODE ###

from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

if __name__ == "__main__":
    main()
N, K = map(int, raw_input().split())
array=[10^5+1]*K
for i in range(N):
 a,b=map(int, raw_input().split())
 for j in range(K):
  if a<array[j] and 0<b:
   array[j]=a
   b=b-1
array.sort()
print array[K-1]

### FIXED CODE ###

N, K = map(int, raw_input().split())
array=[]
for i in range(N):
 l=map(int, raw_input().split())
 array.append(l)
array.sort()
num=0
for j in range(N):
 num=num+array[j][1]
 if K<=num:
  print array[j][0]
  break;
h,w = map(int,input().split())
s = [list(input()) for i in range(h)]
edge = [(0,1),(0,-1),(1,0),(-1,0)]
ans = []
for i in range(h):
    for j in range(w):
        if s[i][j] =="#":
            for x,y in edge:
                if 0<= i+x <w and 0<= j+y < h and s[i+x][j+y] =="#":break #三番目のforから抜け出す
            else:
                print("No")
                break #二番目
    else:continue
    break
else:print("Yes")


### FIXED CODE ###

h,w = map(int,input().split())
s = [list(input()) for i in range(h)]
edge = [(0,1),(0,-1),(1,0),(-1,0)]
for i in range(h):
    for j in range(w):
        if s[i][j] =="#":
            for x,y in edge:
                if 0<= i+y <h and 0<= j+x < w and s[i+y][j+x] =="#":break #三番目のforから抜け出す
            else:
                print("No")
                break #二番目
    else:continue
    break
else:print("Yes")
import math
n,m=map(int,input().split())
s=input()
t=input()
p=math.gcd(n,m)
ans=n*m//p
tt=[0 for _ in range(ans)]
for i in range(n):
	tt[i*(ans//n)]=s[i]
for i in range(m):
	if tt[i*(ans//m)]!=t[i] and tt[i*(ans//m)]!="":
		print(-1)
		exit()
print(ans)


### FIXED CODE ###

from fractions import gcd
n,m=map(int,input().split())
s=input()
t=input()
p=gcd(n,m)
ans=n*m//p 
for i in range(n):
	if abs((i*(ans//n)/(ans//m))-int(i*(ans//n)/(ans//m)))<=10**(-7):
		if s[i]==t[(i*(ans//n)//(ans//m))]:
			continue
		else:
			print(-1)
			exit()
print(ans)
a, b, c = list(map(int, input().split()))
print(a[0].upper() + a[1].upper() + a[2].upper())

### FIXED CODE ###

a, b, c = list(map(str, input().split()))
print(a[0].upper() + b[0].upper() + c[0].upper())
n = int(input())
h = list(map(int,input().split()))

for i in range(n-1):
  if h[i] == h[i+1]+1:
    j = i
    p = 1
    break
  elif h[i] >= h[i+1] + 2:
    p = 2
    break
  else:
    j = 0
    p = 3
    
if min(h[j:]) + 2 <= h[j] or p == 2:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

n = int(input())
h = list(map(int,input().split()))
d = [1]+[0]*(n-1)

for i in range(n-1):
  if h[i] >= 2+ h[i+1]:
    print('No')
    exit()
  if d[i] == 1 and h[i] <= h[i+1]:
    d[i+1] = 1
  elif d[i] == 0:
    if h[i] +1 <=h[i+1]:
      d[i+1] = 1
    elif h[i] -1 == h[i+1]:
      print('No')
      exit()
      
print('Yes')
S = input()
T = input()

c = 0
for i in range(len(S)):
  if S[i] != T[i]:
    C += 1
    
print(c)

### FIXED CODE ###

s=input()
t=input()
ans=0
for i in range(len(s)):
    ans+=(s[i]!=t[i])
print(ans)
import sys
input_lines = sys.stdin.readlines()
a,b = input_lines.split( )

if(b%a==0):
  print(a+b)
else:
  print(b-a)

### FIXED CODE ###

import sys
input_lines = sys.stdin.readline()
a,b = input_lines.split( )

a = int(a)
b = int(b)

if(b%a==0):
  print(a+b)
else:
  print(b-a)
import typing as tp
import fileinput
    
def frog(stones):
    stone_cost = [0]
    for i in range(1, len(stones)):
        single_step_cost = abs(stones[i] - stones[i - 1])
        if i == 1:
            stone_cost.append(single_step_cost)
        else:
            double_step_cost = abs(stones[i] - stones[i - 2])
            stone_cost.append(min(single_step_cost + stone_cost[-1], double_step_cost + stone_cost[-2]))
    
    return stone_cost[-1]
    
    
inp = fileinput.input()
inp.readline()
stones = [int(v) for v in inp.readline().split(" ") if v != "\n"]
print(frog(stones))

### FIXED CODE ###

import fileinput
    
def frog(stones):
    stone_cost = [0]
    for i in range(1, len(stones)):
        single_step_cost = abs(stones[i] - stones[i - 1])
        if i == 1:
            stone_cost.append(single_step_cost)
        else:
            double_step_cost = abs(stones[i] - stones[i - 2])
            stone_cost.append(min(single_step_cost + stone_cost[-1], double_step_cost + stone_cost[-2]))
    
    return stone_cost[-1]
    
    
inp = fileinput.input()
inp.readline()
stones = [int(v) for v in inp.readline().split(" ")]
print(frog(stones))
N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
print(sum(H[N-K]))

### FIXED CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
if N <= K:
  print(0)
else:
  print(sum(H[:N-K]))
s = str(input())
for i in range(3):
	if s[i] == "o":
		cnt += 1
print(700+100*cnt)

### FIXED CODE ###

s = str(input())
cnt = 0
for i in range(3):
	if s[i] == "o":
		cnt += 1
print(700+100*cnt)
n=int(input())

a = 0
for i in range(n):
    li = input().split()
        a+=1
    elif(a<3):
        a=0
    else:
        print("Yes")
        exit()
if(a>2):
    print("Yes")
    exit()

print("No")

### FIXED CODE ###

n=int(input())

a = 0
for i in range(n):
    li = input().split()
    if(li[0]==li[1]):
        a+=1
    elif(a<3):
        a=0
    else:
        print("Yes")
        exit()
if(a>2):
    print("Yes")
    exit()

print("No")
#!/usr/bin/python3                                                                                                                                                                                          

import itertools

def all_comb(n):
    comb = []
    for i in range(0, n+1):
        comb.extend(list(itertools.combinations(range(n), i)))
    return comb

if __name__=='__main__':
    str = input()
    comb = all_comb(len(str)-1)
    tail = 0
    sum = 0
    for plus_positions in comb:
        head = 0
        for plus_position in plus_positions:
            num = int(str[head:plus_position+1])
            sum += num
            head = plus_position + 1
        num = int(str[head:])
	sum += num
    print(sum)


### FIXED CODE ###

#!/usr/bin/python3                                                                                                                                                                                          

import itertools

def all_comb(n):
    comb = []
    for i in range(0, n+1):
        comb.extend(list(itertools.combinations(range(n), i)))
    return comb

if __name__=='__main__':
    str = input()
    comb = all_comb(len(str)-1)
    tail = 0
    sum = 0
    for plus_positions in comb:
        head = 0
        for plus_position in plus_positions:
            num = int(str[head:plus_position+1])
            sum += num
            head = plus_position + 1
        num = int(str[head:])
        sum += num
    print(sum)
values = []
i = 0
while True:
    values.append([int(x) for x in input().split()])
    if [] == values[i] and 0 == len(values[i]):
        values.pop()
        break
    else:
        i += 1

sum = 0
digit = 0
for x, y in values:
    sum = x + y
    digit = 0
    while sum >= 1:
        sum //= 10
        digit += 1
    print(digit)

### FIXED CODE ###

import sys
values = []
for line in sys.stdin:
    values.append([int(x) for x in line.split()])
digit = 0
for x, y in values:
    sum = x + y; digit = 0
    while sum >= 1:
        sum //= 10
        digit += 1
    print(digit)
# 座標を入力
sx, sy, tx, ty = map(int, input())
S = np.array([sx, sy])
T = np.array([tx, ty])

# 2点の最短経路を返す関数を定義（左右移動優先かつ方向転換1回のみ） 
def shortest_path(start, end):
    if start[0] <= end[0]:
        lr_path = "R" * (end[0] - start[0])
    else:
        lr_path = "L" * (start[0] - end[0])
    if start[1] <= end[1]:
        ud_path = "U" * (end[0] - start[0])
    else:
        ud_path = "D" * (start[0] - end[0])
    return lr_path + ud_path

# 点Sから点Tまでの経路（1回目）
path_1 = shortest_path(S, T)
# 点Tから点Sまでの経路（1回目）
path_2 = shortest_path(T, S)
# 点Sから点Tまでの経路（2回目）
path_3 = "D" + shortest_path(S + np.array([0, -1]), T + np.array([1, 0])) + "L"
# 点Tから点Sまでの経路（2回目）
path_4 = "L" + shortest_path(S + np.array([-1, 0]), T + np.array([0, 1])) + "D"
# 全経路を出力
print(path_1 + path_2 + path_3 + path_4)

### FIXED CODE ###

import numpy as np
# 座標を入力
sx, sy, tx, ty = map(int, input().split())
S = np.array([sx, sy])
T = np.array([tx, ty])

# 2点の最短経路を返す関数を定義（左右移動優先かつ方向転換1回のみ） 
def shortest_path(start, end):
    if start[0] <= end[0]:
        lr_path = "R" * (end[0] - start[0])
    else:
        lr_path = "L" * (start[0] - end[0])
    if start[1] <= end[1]:
        ud_path = "U" * (end[1] - start[1])
    else:
        ud_path = "D" * (start[1] - end[1])
    return lr_path + ud_path

# 点Sから点Tまでの経路（1回目）
path_1 = shortest_path(S, T)
# 点Tから点Sまでの経路（1回目）
path_2 = shortest_path(T, S)
# 点Sから点Tまでの経路（2回目）
path_3 = "D" + shortest_path(S + np.array([0, -1]), T + np.array([1, 0])) + "L"
# 点Tから点Sまでの経路（2回目）
path_4 = "U" + shortest_path(T + np.array([0, 1]), S + np.array([-1, 0])) + "R"
# 全経路を出力
print(path_1 + path_2 + path_3 + path_4)
N,M = input().split()
s,c,a = [],[],[]
number = []
for i in range(int(M)):
    a_i = input().split()
    a.append(a_i)
    s.append(int(a_i[0]))
    c.append(int(a_i[1]))
ans = True
for i in range(int(M)):
    number.append('')
for i in range(int(M)):
    if s[i]==1 and c[i]==0:
        print('-1')
        ans = False
    elif number[s[i]-1] == '' or number[s[i]-1] == c[i]:
        number[s[i]-1] = c[i]
    else:
        if ans:
            print('-1')
            ans = False
for i,elem in enumerate(number):
    if elem == '' and i == 0:
        number[i] = 1
    if elem == '':
        number[i] = 0
if ans:
    strs = '' 
    for i in number:
        strs += str(i)
    print(int(strs))

### FIXED CODE ###

N,M = input().split()
s,c,a = [],[],[]
number = []
for i in range(int(M)):
    a_i = input().split()
    a.append(a_i)
    s.append(int(a_i[0]))
    c.append(int(a_i[1]))
ans = True
for i in range(int(N)):
    number.append('')
for i in range(int(M)):
    if s[i]==1 and c[i]==0 and int(N)>1:
        if ans:
            print('-1')
            ans = False
    elif s[i] > int(N):
        if ans:
            print('-1')
            ans = False
    elif number[s[i]-1] == '' or number[s[i]-1] == c[i]:
        number[s[i]-1] = c[i]
    else:
        if ans:
            print('-1')
            ans = False
for i,elem in enumerate(number):
    if number[i] == '' and i == 0 and int(N) >1:
        number[i] = 1
    elif elem == '':
        number[i] = 0
if ans:
    strs = '' 
    for i in number:
        strs += str(i)
    print(int(strs))
if contest_num <= 999:
    print('ABC' + str(contest_num).zfill(3))
elif contest_num >= 1000:
    over_thousand_num_fix = contest_num - 999
    print('ABD' + str(over_thousand_num_fix).zfill(3))

### FIXED CODE ###

contest_num = int(input())

if contest_num <= 999:
    print('ABC')
elif contest_num >= 1000:
    print('ABD')
import math
k= int(input())
ans = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      g = math.gcd(a,b,c)
      ans = ans + g
print(ans)

### FIXED CODE ###

import math
n=int(input())
ans=0
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      ans+=math.gcd(i,math.gcd(j,k))
print(ans)
n=list(input())
print('Yes' if n[0]==n[1]==n[2] or n[3]==n[1]==n[2] or n[2]==n[3]==n[4] else 'No')

### FIXED CODE ###

n=list(input())
print('Yes' if n[0]==n[1]==n[2] or n[3]==n[1]==n[2] or  n[0]==n[2]==n[3]==n[1] else 'No')
S = list(input())
if S[0] != 'A':
    print('WA')
    exit

S_aida = S[2:-1]
if S_aida.count("C") != 1:
    print('WA')
    exit

S.pop(0)
S.pop(S.index('C'))

for string in S:
    if not string.islower():
        print('WA')
        exit

print('AC')


### FIXED CODE ###

import sys

S = list(input())
if S[0] != 'A':
    print('WA')
    sys.exit()

S_aida = S[2:-1]
if S_aida.count("C") != 1:
    print('WA')
    sys.exit()

S.pop(0)
S.pop(S.index('C'))

for string in S:
    if not string.islower():
        print('WA')
        sys.exit()

print('AC')
import sys

lines='''105
'''
sys.stdin = io.StringIO(lines)

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(n):
    yakusuu_array=[] 
    for x in range(1,n+1): 
        if n%x == 0: 
            yakusuu_array.append(x) 
    a=len(yakusuu_array)
    #print(yakusuu_array)
    if a >= 8 and n%2 != 0 and 1 <= n and n <=200:
        return 1 
    else: 
        return 0

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    return int(line)

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(n):
    listc = []
    for i in range(1,201):
        lista = []
        for j in range(1,201):
            if i%j == 0:
                lista.append(j)
        if len(lista) >= 8 and lista[-1] %2 != 0:
            listc.append(lista[-1])
    #print(listc)#デバッグ用
    for i in range(len(listc)):
        if n < listc[0]:
            return 0
        elif n >= listc[-(i+1)]:
            return len(listc)-i

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    return int(line)

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
if __name__ == '__main__':
    main()
n=int(input())
s=list(input() for _ in range(n))
m,i,f,both=0,0,0,0

for i in range(n):
    m +=s[i].count("AB")
    if s[i][0]=="B":
        i +=1
    if s[i][1]=="A":
        f +=1
    if s[i][0]=="B" and s[i][1]=="A":
        both+=1
        i-=1
        f-=1

if both!=0:
    if i!=0 and f!=0:
        print(m+both+min(i,f)-1)
    else:
        print(m+both+min(i,f))

else:
    print(min(i,f))


### FIXED CODE ###

n,k=list(map(int,input().split()))
print(n-k+1)
n = int(input())
left = [None for _ in range(n)]
right = [None for _ in range(n)]
root = set(range(n))

for i in range(n):
    i, l, r = map(int, input().split())
    left[i] = l
    right[i] = r
    root -= {l, r}

    root_n = root.pop()

def Preorder(i):
    if i == -1:
        return
    print(" {}".format(i), end = "")
    Preorder(left[i])
    Preorder(right[i])

def Inorder(i):
    if i == -1:
        return
    Inorder(left[i])
    print(" {}".format(i), end = "")
    Inorder(right[i])

def Postorder(i):
    if i == -1:
        return
    Postorder(left[i])
    Postorder(right[i])
    print(" {}".format(i), end = "")

print("Preorder")
Preorder(root_n)
print()

print("Inorder")
Inorder(root_n)
print()

print("Postorder")
Postorder(root_n)
print

### FIXED CODE ###

n = int(input())
left = [None for i in range(n)]
right = [None for i in range(n)]
root = sum(range(n)) - n - 1

for i in range(n):
    i, l, r = map(int, input().split())
    left[i] = l
    right[i] = r
    root -= (l + r)

def Preorder(i):
    if i == -1:
        return
    print(" {}".format(i), end = "")
    Preorder(left[i])
    Preorder(right[i])

def Inorder(i):
    if i == -1:
        return
    Inorder(left[i])
    print(" {}".format(i), end = "")
    Inorder(right[i])

def Postorder(i):
    if i == -1:
        return
    Postorder(left[i])
    Postorder(right[i])
    print(" {}".format(i), end = "")

print("Preorder")
Preorder(root)
print()

print("Inorder")
Inorder(root)
print()

print("Postorder")
Postorder(root)
print()
N = int(input())
ans = []
n = N//2
if N == 3:
    ans = [2,3,63]
elif 4 <= N <= 15000:
    for i in range(1,n):
        ans.append(2*i)
        x = 30000 - 2*i
        ans.append(x)
    if N % 2 == 0:
        ans.append(30000)
    ans.append(3)
    ans.append(9)
else:
    for i in range(1,15000):
        ans.append(2*i)
    x = N - 14999
    for j in range(x):
        y = 6*x + 3
        if y <= 30000:
            ans.append(y)
    if N == 20000:
        ans.append(30000)
print(*ans)
    


### FIXED CODE ###

S = input()
L = [i for i in range(97,123)]
n = len(S)
for i in range(n):
    L.remove(ord(S[i]))
if n <= 25:
    X = L[0]
    ans = S + chr(X)
else:
    T = []
    x = S[-1]
    T.append(x)
    for i in range(2,27):
        y = S[-i]
        if y > x:
            x = y
            T.append(y)
        else:
            break
    m = 26 - len(T)
    if m > 1:
        ans = S[0]
        for i in range(1,m-1):
            ans += S[i]
        for t in T:
            if t > S[m-1]:
                ans += t
                break
    elif m == 0:
        ans = -1
    else:
        for t in T:
            if t > S[m-1]:
                ans = t
                break
print(ans)
import itertools
import math

def solve():
  N, D = [int(s) for s in input().split() if s]
  X = []
  cnt = 0
  for _ in range(N):
    X.append([int(s) for s in input().split() if s])
    for x1,x2 in itertools.combinations(X,2):
      if dist(x1,x2).is_integer():
        cnt+=1
    print(cnt)

solve()

### FIXED CODE ###

import itertools
import math

dist = lambda X,Y: math.sqrt(sum((x-y)**2 for x,y in zip(X,Y)))

def solve():
    N, D = [int(s) for s in input().split() if s]
    X = []
    cnt = 0
    for _ in range(N):
        X.append([int(s) for s in input().split() if s])
    for x1,x2 in itertools.combinations(X,2):
        if dist(x1,x2).is_integer():
            cnt+=1
    print(cnt)

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

town = 1
count = 0
town_visited = set()
while count < k:
    town_visited.add(town)
    town = a_l[town-1]
    count += 1
    if town in town_visited:
        break

k -= count
count = 0
town_visited = set()
while count < k:
    town_visited.add(town)
    town = a_l[town-1]
    count += 1
    if town in town_visited:
        break

remain = k%count
count = 0
while count < remain:
    town = a_l[town-1]
    count += 1
   
print(town)

### FIXED CODE ###

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

town = 1
count = 0
town_visited = set()
while count < k:
    town_visited.add(town)
    town = a_l[town-1]
    count += 1
    if town in town_visited:
        break

k -= count
if k == 0:
    print(town)
    exit()
count = 0
town_visited = set()
while count < k:
    town_visited.add(town)
    town = a_l[town-1]
    count += 1
    if town in town_visited:
        break

remain = k%count
count = 0
while count < remain:
    town = a_l[town-1]
    count += 1
   
print(town)
inn = int(input())
    r = 0
    for i in range(1,inn+1):
      r += i
    print(r)

### FIXED CODE ###

inn = int(input())
r = 0
for i in range(1,inn+1):
  r+= i
print(r)
N = int(input())
a = list(map(int, input().split()))
 
x = 0
y = 0
z = 0
 
if N % 3 != 0:
  print('No')
 
else:
 
  for i in range(N):
    if a[i] != x and a[i] != y and a[i] != z:
      if x == 0:
        x = a[i]
        continue
      elif y == 0:
        y = a[i]
        continue
      elif z == 0:
        z = a[i]
        continue
      else:
        print('No')
        sys.exit()
 
  if x ^ y == z:
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

import sys

N = int(input())
a = list(map(int, input().split()))
 
x = 0
y = 0
z = 0

if a.count(0) == N:
  print('Yes')
  sys.exit()
  

if N % 3 != 0:
  print('No')
 
elif a.count(0) != 0:
  if a.count(0) != N / 3:
    print('No')
    sys.exit()
    
  else:
    for i in range(N):
      if a[i] != 0 and a[i] != x:
        if x == 0:
          x = a[i]
          continue
        else:
          print('No')
          sys.exit()
        
    print('Yes')
    

else:
  for i in range(N):
    if a[i] != x and a[i] != y and a[i] != z:
      if x == 0:
        x = a[i]
        continue
      elif y == 0:
        y = a[i]
        continue
      elif z == 0:
        z = a[i]
        continue
      else:
        print('No')
        sys.exit()
  
  if x ^ y == z and a.count(x) == a.count(y) and a.count(y) == a.count(z):
    print('Yes')
  else:
    print('No')