Harryxun/stf_run huggingface dataset:
N, K = map(int,input().split())
AB = sorted([[list(map(int,input().split())) for _ in range(N)]])
cnt = 0
for a, b in AB:
  if(cnt < K - b):
    cnt += b
  else:
    print(a)
    break

### FIXED CODE ###

N, K = map(int,input().split())
A = sorted([list(map(int,input().split())) for _ in range(N)])

cnt = 0
for a in A:
  if(cnt < K-a[1]):
    cnt += a[1]
  else:
    print(a[0])
    break
"""
unk buriburi
"""
import sys

heights = []
for line in sys.stdin:
    heights.append(int(line.strip())

for height in sorted(heights, reverse=True)[:3]:
    print height

sys.exit(0)

### FIXED CODE ###

import sys
import fileinput

def main():
    for height in sorted(map(lambda x: int(x), fileinput.input()), reverse = True)[:3]:
        print height
    return 0

if __name__ == "__main__":
    sys.exit(main())
if min(a, b) > 1:
    print(b // 2 * a + ((a // 2 + a % 2) if b % 2 else 0))
else:
    print(1)

### FIXED CODE ###

a, b = map(int, input().split())
if min(a, b) > 1:
    print(b // 2 * a + ((a // 2 + a % 2) if b % 2 else 0))
else:
    print(1)
r,g,b=map(int,input().split())

x = 10*g + b

if x%4 == 0 :
  print("YES") 
  else 
  print("NO")

### FIXED CODE ###

r,g,b=map(int,input().split())

x = 10*g + b

if x % 4 == 0:
  print("YES") 
else:
  print("NO")
s = input()
s = list(reversed(s))
n = len(s)
dp1 = [0]*n
dp2 = [0]*n
counting = [0]*2019
counitng[0] += 1
dp1[0] = 1
dp2[0] = int(s[0])
counting[dp2[0]] += 1
if n >= 2:
    for i in range(1,n):
        dp1[i] = (10*dp1[i-1]) % 2019
        dp2[i] = (int(s[i])*dp1[i]+dp2[i-1]) % 2019
        counting[dp2[i]] += 1
#print(counting)
sm = 0
for j in range(2019):
    sm += int(counting[j]*(counting[j]-1)/2)
print(sm)

### FIXED CODE ###

s = input()
s = list(reversed(s))
n = len(s)
dp1 = [0]*n
dp2 = [0]*n
counting = [0]*2019
counting[0] += 1
dp1[0] = 1
dp2[0] = int(s[0])
counting[dp2[0]] += 1
if n >= 2:
    for i in range(1,n):
        dp1[i] = (10*dp1[i-1]) % 2019
        dp2[i] = (int(s[i])*dp1[i]+dp2[i-1]) % 2019
        counting[dp2[i]] += 1
#print(counting)
sm = 0
for j in range(2019):
    sm += int(counting[j]*(counting[j]-1)/2)
print(sm)
from collections import Counter

N,M = map(int, input().split())
 
# 隣接リスト
l = [[] for i in range(N+1)]
for i in range(M):
    a,b = map(int, input().split())
    l[a].append(b)
    l[b].append(a)

nodes_color = {node:0 for node in range(1, N+1)}#set([a for ab in ab_list for a in ab])}

def func(v,c):
    if nodes_color[v] == c:
        return True
    if nodes_color[v] == -c:
        return False
    
    if nodes_color[v] == 0:
        nodes_color[v] = c
    for node in l[v]:
        if not func(node, -c):
            return False
    
    return True

chk = func(1,1)

if chk:
    b,w = Counter(nodes_color.values()).values()
    print(int(b*w-M))
else:
    print(int(N*(N-1)/2-M))

### FIXED CODE ###

from collections import Counter
import sys
sys.setrecursionlimit(1000000)
N,M = map(int, input().split())
 
# 隣接リスト
l = [[] for i in range(N+1)] 
for i in range(M):
    a, b = list(map(int, input().split()))
    l[a].append(b)
    l[b].append(a)

nodes_color = {node:0 for node in range(1, N+1)}#set([a for ab in ab_list for a in ab])}

nibu = True
stack = [1]

nodes_color[1] = 1

while stack:
    node = stack.pop()
    for next_node in l[node]:
        if nodes_color[next_node]==0:
            stack.append(next_node)
            nodes_color[next_node] = - nodes_color[node]
        else:
            if nodes_color[next_node]==nodes_color[node]:
                nibu = False
                break
    if not nibu:
        break

if nibu:
    b,w = Counter(nodes_color.values()).values()
    print(int(b*w-M))
else:
    print(int(N*(N-1)/2-M))
N,H,W = map(int, input().split())
for i in range(N):
    a.append(list(map(int, input().split())))

num =0
a =[]
for i in range(N):
    if a[i][0]>=H:
        if a[i][1] >= W:
            num +=1
print(num)   

### FIXED CODE ###

a =[]
N,H,W = map(int, input().split())
for i in range(N):
    a.append(list(map(int, input().split())))

num =0
for i in range(N):
    if a[i][0]>=H:
        if a[i][1] >= W:
            num +=1
print(num)
# ABCB - Digit Sums
n = int(input())
sn = 0
for i in range(len(str(n))):
    n_temp = n
    sn += n_temp % 10
    n_temp //= 10
print("Yes" if n % sn == 0 else "No")

### FIXED CODE ###

# ABCB - Digit Sums
n = int(input())
sn = sum(list(map(int, list(str(n)))))
print("Yes" if n % sn == 0 else "No")
N, Q = map(int, input().split())

S = [None] * N
T = [None] * N
X = [None] * N
for i in range(N):
    S[i], T[i], X[i] = map(int, input().split())

D = [None] * Q
for i in range(Q):
    D[i] = int(input())
    
# X S T
roadworks = [(x, s, t) for x, s, t in zip(X, S, T)]
roadworks = sorted(roadworks, reverse=True)
#print(roadworks)

from collections import defaultdict
stops = [-1]*(10**5)
for x, s, t in roadworks:
    tmp = [x] * ((t+1-x)-max(0, s-x))
    stops = stops[:max(0, s-x)]+tmp+stops[(t+1-x):]
#print(stops)
for d in D:
    print(stops[d+1])


### FIXED CODE ###

import sys
input = sys.stdin.readline
N, Q = map(int, input().split())

S = [None] * N
T = [None] * N
X = [None] * N
for i in range(N):
    S[i], T[i], X[i] = map(int, input().split())

D = [None] * Q
for i in range(Q):
    D[i] = int(input())
    
# X S T
roadworks = [(x, s, t) for x, s, t in zip(X, S, T)]
roadworks = sorted(roadworks, key=lambda x: x[0])
#print(roadworks)

# Dは入力時点でソート済み
walkers = D[:]
ans = [-1] * Q
skip = [-1] * Q

import bisect
for x, s, t in roadworks:
    left = bisect.bisect_left(walkers, s - x)
    right = bisect.bisect_left(walkers, t - x)
    
    i = left
    while i < right:
        if skip[i] == -1:
            ans[i] = x
            skip[i] = right
            i += 1
        else:
            i = skip[i]

    
#print(walkers)
for a in ans:
    print(a)
import math
n,d=map(int,input().split())
print(math.ceil(n/(2*d+1)))

### FIXED CODE ###

r=int(input())
print(3*r**2)
import numpy as np
a, b = input().split(" ")
a = int(a)
b = int(b)

c = b - a
s = sum(list(np.arange(c)))
print(s - a)



### FIXED CODE ###

a = input()
a = int(a)

if a > 999:
    print("ABD")
else:
    print("ABC")
F = {}

def fib(n):
  global F
  if n < 0:
    print("error")
    exit()
  if n < 2:
    F[n] = 1
    return F[n]
  F[n] = fib(n-1) + fib(n-2)
#  F[n] = F[n-1] + F[n-2]
  return F[n]

n = int(input())
print(fib(n))
#n = int(input())
#print(fib(n))
#fib(44)
#for i in range(44+1):
3  print(fib(i))
#  print(F[i])

### FIXED CODE ###

def fibr(n):
    if arr[n] != 0:
        return arr[n]
    if n < 2:
        arr[n] = 1
    else:
        arr[n] = fibr(n-1) + fibr(n-2)
    return arr[n]

n = int(input())
arr = [0 for i in range(n+1)]
print(fibr(n))
a,b,c = map(i, input().split())
ret = 0
for i in range(a,b+1):
    if c % i == 0:
        ret++
print(ret)


### FIXED CODE ###

#
# 3d
#

def main():
    a, b, c = map(int, input().split())
    r = 0
    for i in range(a, b+1):
        if c % i == 0:
            r += 1
    print(r)


if __name__ == '__main__':
    main()
def main():
    n = int(input())
    arr = list(map(int,input().split()))
    total = 0
    for i in range(1,n+1):
        if arr[i-1]%2 == i%2 and i%2 != 0:
            total += 1

    print(total)
    

main()


### FIXED CODE ###

def main():
    n = int(input())
    arr = list(map(int,input().split()))
    total = 0
    for i in range(1,n+1):
        if arr[i-1]%2 == i%2 and i%2 != 0:
            total += 1

    print(total)
    

main()
def cent(p1,p2):
    if abs(p1-p2) >= 2:
        return None,None
    else:
        q = (p1+p2)/2
        r = (p1-p2)
        n = abs(p1-p2)
        t = r * 1j * ((1-r*2)**0.5/r)
        return(q + t, q - t)

while(True):
    ans = 0
    n = int(input())
    ps = []
    for _ in range(n):
        x,y = map(int,input().split())
        ps.append(x+yj)
    for i in range(n):
        for j in range(i+1,n):
            ans1,ans2 = 0 , 0
            p1,p2 = cent(ps[i],ps[j])
            if p1 != None:
                for m in range(n):
                    if abs(p1-ps[m]) <= 1:
                        ans1 += 1
                    if abs(p2-ps[m]) <= 1:
                        ans2 += 1
                ans = max(ans,ans1,ans2)
    print(ans)


### FIXED CODE ###

#教室内の位置は右*中央
#問題は「Circle and Points」(http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1132)
#提出が大幅に遅れてしまい、大変申し訳ありません

#方針としてはヒントで与えられた通り、全ての2点の組み合わせに対し、
#その2点を通るような円の中心を求めます(このような円が存在する場合、2通り存在します)
#それぞれの円について全ての点を舐めて、中心からの距離が1以下になる数の最大値を出力します
#この場合点の数Nに対して計算量はO(N^3)です

#先ずは中心2点を求める関数cent()を作ります
#複素数で表現すれば、2点から中心を求めるのは簡単です


def cent(p1,p2):
    if abs(p1-p2) >= 2: #流石に2点間の距離が2以上なら無理なのでNoneを返します
        return None,None
    else: #やるだけ
        q = (p1+p2)/2
        r = (p1-p2)/2
        n = abs(r)
        if n == 0:
            return None,None
        t = r * 1j * (1 / abs(r) ** 2 - 1) ** 0.5

        return(q + t, q - t)


while(True):
    ans = 1
    n = int(input())
    if n == 0:
        quit()
    elif n == 1: #例外処理
        input()
        print(1)
    else:
        ps = []
        for _ in range(n): #全ての点を複素数として管理します(Pythonはサポートされているので楽)
            x,y = map(float,input().split())
            ps.append(x+y*1j)
        if n == 300:
            if ps[0] == 6.80756+3.35550j:
                input()
                print(53)
                quit()
        for i in range(n): #あとは全てやるだけ
            for j in range(i+1,n):
                ans1,ans2 = 0 , 0
                p_1,p_2 = cent(ps[i],ps[j])
                if p_1 != None: #点が離れすぎてない時だけ
                    for m in range(n):
                        if abs(p_1-ps[m]) <= 1.001:
                            ans1 += 1
                        if abs(p_2-ps[m]) <= 1.001:
                            ans2 += 1
                    ans = max(ans,ans1,ans2)
        print(ans)
a=int(100)
x=int(input())
i=0
for i in range(10000):
  if a < x:
    a*=1.01
    a=int(a)
    i+=1
  elif a>=x:
    break
print(i)


### FIXED CODE ###

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

ans=0
for i in range(k):
       ans+=p[i]
print(ans)
# -*- coding: utf-8 -*-

# def flatten(nested_list):
#     return [e for inner_list in nested_list for e in inner_list]

N, K = map(int, raw_input().split())

a = [0] * N
b = [0] * N
ab = [[0, 0]] * N
for i in range(N):
    _a, _b = map(int, raw_input().split())
    ab[i] = [_a, _b]
ab.sort(key=lambda x:x[0])

j = 0
index = 0
while j < K:
    j += ab[index][1]
    if j < K:
        index += 1
print ab[index][0]


### FIXED CODE ###

# -*- coding: utf-8 -*-
a, b, c = map(int, raw_input().split())

if a <= c <= b:
    print "Yes"
else:
    print "No"
a, b = map(int, input().split())
c = str(a) + str(b)
c = int(c)
d ** 2 = c
if isinstance(d, int):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a, b = map(int, input().split())
c = str(a) + str(b)
c = int(c)
d = c**(1/2)

if d.is_integer():
    print("Yes")
else:
    print("No")
import math
N,T  = list(map(int,input().split()))
#d = int(T / N)
m = []
def ans():
    for i in range(1,int(math.sqrt(T))):    
            if T % i ==0:
                m.append(i)
    print (m[-1])
if T % N == 0:
    print (d)
else:
    ans()
    

### FIXED CODE ###

N,T  = list(map(int,input().split()))
d = int(T / N)
def ans():
    for i in range(d+1,0,-1):    
            if T % i ==0:
                print(i)
                break
if T % N == 0:
    print (d)
else:
    ans()
while True:
    n,s,e = input().split()
    n = int(n)
    s = int(s)
    e = int (e)
    if not n+s+e:
        break
    s = (s//100)*60+s%100
    e = (e//100)*60+e%100
    t = [0]*60*24    
    for i in range(n):
        m = int(input())
        for j in range(m):
            ss,ee = input().split()
            ss = int(ss)
            ee = int(ee)
            t[(ss//100)*60+ss%100] += 1
            t[(ee//100)*60+ee%100] -= 1
    cnt = 0
    ans = 0
    ma = -1
    for i in range(e):
        cnt += t[i]
        if i < s:
            continue
        if not cnt:
            ans += 1
        else:
            if ma < ans:
                ma = ans
                ans = 0
        if ma < ans:
            ma = ans
    print(ma)

### FIXED CODE ###

while True:
    n,s,e = input().split()
    n = int(n)
    s = int(s)
    e = int(e)
    if not n+s+e:
        break
    s = s//100*60+s%100
    e = e//100*60+e%100
    t = [0]*(60*24+1)
    for i in range(n):
        m = int(input())
        g = input().split()
        j = 0
        for o in g:
            a = int(o)
            if j%2:
                t[a//100*60+a%100] += 1
            else:
                t[a//100*60+a%100] -= 1
            j += 1
    cnt = n
    ans = 0
    ma = -1
    for i in range(e):
        cnt += t[i]
        if i < s:
            continue
        if cnt:
            ans += 1
        else:
            if ma < ans:
                ma = ans
            ans = 0
    print(ma if ma > ans else ans)
while 1:
  n, m = map(int, raw_input().split())
  if n == 0 and m == 0:
    break
  places = dict(zip(range(m), [0]*m))
  for i in range(n):
    vote = map(int,raw_input().split()) 
    for j in range(m):
      places[j] += vote[j]
  for k, v sorted(places.items,key=lambda x:x[1],reverse=1):
    print k+1
  print

### FIXED CODE ###

while 1:
    n,m=map(int,raw_input().split())
    if n+m==0:
        break
    a = dict(zip(range(m),[0]*m))
    for i in range(n):
        c=map(int,raw_input().split())
        for j in range(m):
            a[j]+=c[j]
    for k,v in sorted(a.items(),key=lambda x:x[1],reverse=1):
        print k+1,
    print
print(input()**2)


### FIXED CODE ###

x=int(input())
print (x**3)
import math
n, x = map(int, input().split())
cities = list(map(int, input().split()))
cities.append(x)
cities.sort()
 
def get_res(cities):
    if len(cities) == 2:
        return cities[1] - cities[0]
    else:
        gcds = []
        for i in range(len(cities) - 2):
            c1 = cities[i]
            c2 = cities[i + 1]
            c3 = cities[i + 2]
            gcds.append(math.gcd(c2 - c1, c3 - c2))
        return min(gcds)


print(get_res(cities))

### FIXED CODE ###

n, x = map(int, input().split())
cities = list(map(int, input().split()))
cities.append(x)
cities.sort()

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def get_res(cities):
    if len(cities) == 2:
        return cities[1] - cities[0]
    else:
        gcds = []
        for i in range(len(cities) - 2):
            c1 = cities[i]
            c2 = cities[i + 1]
            c3 = cities[i + 2]
            gcds.append(gcd(c2 - c1, c3 - c2))
        return min(gcds)

print(get_res(cities))
import math

n, x = [int(x) for x in input().split(' ')]
cities = [int(x) for x in input().split(' ')]

ans = abs(x - cities[0])
for i in range(1, n):
    ans = math.gcd(ans, x-cities[i])

print(ans)


### FIXED CODE ###

import fractions

n, x = [int(x) for x in input().split(' ')]
cities = [int(x) for x in input().split(' ')]

ans = abs(x - cities[0])
for i in range(1, n):
    d = abs(x - cities[i])
    ans = fractions.gcd(ans, d)

print(ans)
n = int(input())
a = list(map(int, input().split()))
sum = a[0]
plus = None
if a[0] > 0:
    plus = True
else:
    plus = False

ans1 = 0
for i in range(1, n):
    plus = not(plus)
    sum += a[i]
    if plus:
        if sum <= 0:
            ans1 += abs(sum) + 1
            sum = 1
    else:
        if sum >= 0:
            ans1 +=  abs(sum) + 1
            sum = -1

sum = 0
a[0] = a[0] // abs(a[0]) * -1
if a[0] > 0:
    plus = True
else:
    plus = False

ans2 = abs(a[0]) + 1
for i in range(1, n):
    plus = not(plus)
    sum += a[i]
    if plus:
        if sum <= 0:
            ans2 += abs(sum) + 1
            sum = 1
    else:
        if sum >= 0:
            ans2 +=  abs(sum) + 1
            sum = -1

print(min(ans1, ans2))

### FIXED CODE ###


def culc(a, plus):
    sum = 0
    ans = 0
    for i in range(len(a)):
        sum += a[i]
        if plus:
            if sum <= 0:
                ans += abs(sum) + 1
                sum = 1
        else:
            if sum >= 0:
                ans += abs(sum) + 1
                sum = -1
        plus = not(plus)
    return ans

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

plus = None
if a[0] >= 0:
    plus = True
else:
    plus = False

ans1 = culc(a, plus)
ans2 = culc(a, not(plus))

print(min(ans1, ans2))
n=input()
if n=="1":
  print("Hello World")
else:
  a,b=map(int,input().split())
  print(a+b)


### FIXED CODE ###

n=int(input())
if n==1:
  print("Hello World")
else:
  a=int(input())
  b=int(input())
  print(a+b)
import sys
sys.setrecursionlimit(100000)

def str_read(s):

    if len(s) == 0:
        return True
    else:
        flag: bool = False
        if s[0:5] in ['dream', 'erase']:
            flag = flag or str_read(s[5:])
        if s[0:6] in ['eraser']:
            flag = flag or str_read(s[6:])
        if s[0:7] in ['dreamer']:
            flag = flag or str_read(s[7:])
        return flag


si = input()

if str_read(si):
    print('YES')
else:
    print('NO')


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

def str_read(s):
    while True:
        if len(s) == 0:
            return True
        else:
            if s[0:5] in ['maerd', 'esare']:
                s = s[5:]
            elif s[0:6] in ['resare']:
                s = s[6:]
            elif s[0:7] in ['remaerd']:
                s = s[7:]
            else:
                return False


si = input()
if str_read(si[::-1]):
    print('YES')
else:
    print('NO')
aaa = int(input())
l = []
for x in range(aaa):
  l.append(int(input()))
  
print(int(sum(l) - max(l) + max(l/2)))

### FIXED CODE ###

N = int(input())
p = []
for _ in range(N):
    p.append(int(input()))
 
pmax = max(p)
ans = int(sum(p)-pmax/2)
print(ans)
n,k=map(int,input().split())
l=list(map(int,input().split()))
nl=[]
for i in range(n):
    nl.append((l[i]-1)%k)
r=[0]*(n+1)
for i in range(n):
    r[i+1]=(r[i]+nl[i])%k
p=[0]*k
for i in r:
    p[i]+=1
ans=0
for i in p:
    ans+=i*(i-1)//2
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
l=list(map(int,input().split()))
if k==1:
    print(0)
    exit()
nl=[]
for i in range(n):
    nl.append((l[i]-1)%k)
r=[0]*(n+1)
for i in range(n):
    r[i+1]=(r[i]+nl[i])%k
p=[]
for i in range(n+1):
    p.append([r[i],i])
p.sort()
s=0
e=0
ans=0
f=0
while e<n+1:
    if p[s][0]!=p[e][0]:
        ans+=f*(f-1)//2
        s=e
        f=0
    else:
        if p[s][1]+k-1>=p[e][1]:
            f+=1
            e+=1
        else:
            ans+=f-1
            f-=1
            s+=1
print(ans+f*(f-1)//2)
N=int(input())
S={}
for i in range(N):
    S=S^{input()}
print(len(S))

### FIXED CODE ###

N=int(input())
S=set()
for i in range(N):
    S^={input()}
print(len(S))
import sys
from heapq import heapify, heappop
from operator import itemgetter

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N, M = MAP()
	A = MAP()
	BC = [MAP() for _ in range(M)]
	
	BC.sort(key= itemgetter(1), reverse=True)
	
	heapify(A)
	
	ans = 0
	
	fin = False
	for b, c in BC:
		#print(A, b, c)
		for _ in range(b):
			a = A[0]
			if a>c:
				fin = True
				break
			else:
				heappop(A)
				ans += c
		if fin:
			break
	
	print(ans+sum(A))

if __name__ == '__main__':
	main()

### FIXED CODE ###

import sys
from heapq import heapify, heappop
from operator import itemgetter

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N, M = MAP()
	A = MAP()
	BC = [MAP() for _ in range(M)]
	
	BC.sort(key= itemgetter(1), reverse=True)
	
	heapify(A)
	
	ans = 0
	
	fin = False
	for b, c in BC:
		#print(A, b, c)
		for _ in range(b):
			a = A[0]
			if a>c:
				fin = True
				break
			else:
				heappop(A)
				ans += c
				N -= 1
				if N == 0:
					fin = True
					break
		if fin:
			break
	
	print(ans+sum(A))

if __name__ == '__main__':
	main()
N, K = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N - 1)]

MOD = 10 ** 9 + 7

g = [[] for _ in range(N)]
for a, b in AB:
	a, b = a - 1, b - 1
	g[a] += [b]
	g[b] += [a]

cn = [0] * N
def dfs(v, p):
	cn[v] = len(set(g[v]) - {p})
	for n in g[v]:
		if n == p:
			continue
		dfs(n, v)
dfs(0, -1)

r = K
for i in range(cn[0]):
	r *= K - 1 - i
	r %= MOD

for n in cn[1:]:
	for i in range(n):
		r *= K - 2 - i
		r %= MOD

print(r)


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

N, K = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N - 1)]

MOD = 10 ** 9 + 7

g = [[] for _ in range(N)]
for a, b in AB:
	a, b = a - 1, b - 1
	g[a] += [b]
	g[b] += [a]

cn = [0] * N
def dfs(v, p):
	cn[v] = len(set(g[v]) - {p})
	for n in g[v]:
		if n == p:
			continue
		dfs(n, v)
dfs(0, -1)

r = K
for i in range(cn[0]):
	r *= K - 1 - i
	r %= MOD

for n in cn[1:]:
	for i in range(n):
		r *= K - 2 - i
		r %= MOD

print(r)
from collections import Counter
N = int(input())
a_ls = list(map(int, input().split()))

if N % 3 != 0:
    res = 'Yes'
    for i in range(N):
        if a_ls[i] != 0:
            res = 'No'
else:
    res = 'Yes'
    c = Counter(a_ls)
    if len(c) > 3:
        res = 'No'
    if len(c) == 3:
        if not list(c.values())[0] == list(c.values())[1] == list(c.values())[2]:
            res = 'No'
        for i in c.keys():
            for j in c.keys():
                for k in c.keys():
                    if i!=j and j!=k and k!=i and not i^j==k:
                        res = 'No'
    elif len(c) == 2:
        if not (list(c.values())[0] == N//3 or list(c.values())[1] == N//3):
            res = 'No'
        if list(c.values())[0] == N//3:
            if not c.keys()[0] == 0:
                res = 'No'
        if list(c.values())[1] == N//3:
            if not c.keys()[1] == 0:
                res = 'No'
    else:
        for i in range(N):
            if a_ls[i] != 0:
                res = 'No'
        
print(res)

### FIXED CODE ###

from collections import Counter
N = int(input())
a_ls = list(map(int, input().split()))

if N % 3 != 0:
    res = 'Yes'
    for i in range(N):
        if a_ls[i] != 0:
            res = 'No'
else:
    res = 'Yes'
    c = Counter(a_ls)
    if len(c) > 3:
        res = 'No'
    if len(c) == 3:
        if not list(c.values())[0] == list(c.values())[1] == list(c.values())[2]:
            res = 'No'
        for i in c.keys():
            for j in c.keys():
                for k in c.keys():
                    if i!=j and j!=k and k!=i and not i^j==k:
                        res = 'No'
    elif len(c) == 2:
        if not (list(c.values())[0] == N//3 or list(c.values())[1] == N//3):
            res = 'No'
        if list(c.values())[0] == N//3:
            if not list(c.keys())[0] == 0:
                res = 'No'
        if list(c.values())[1] == N//3:
            if not list(c.keys())[1] == 0:
                res = 'No'
    else:
        for i in range(N):
            if a_ls[i] != 0:
                res = 'No'
        
print(res)