Harryxun/stf_run huggingface dataset:
(n,l)=input().split()
list1=list(input().split())
list1.sort()
for i in range(n)
	print(list1[i]+"")

### FIXED CODE ###

(n,l)=map(int, input().split())
list1=[]
for i in range(n):
	list1.extend(input().split())
list1.sort()
for i in range(n):
	print(list1[i],end="")
n = int(input())
li = [int(input()) for _ in range(n)]

mi = li.index(max(li))
m = max(li)

for a, b in enumerate(li):
  if a != mi:
    print(m)
  else:
    print(max(l[a+1:]+l[:a]))

### FIXED CODE ###

n = int(input())
li = [int(input()) for _ in range(n)]

mi = li.index(max(li))
m = max(li)

for a, b in enumerate(li):
  if a != mi:
    print(m)
  else:
    print(max(li[a+1:]+li[:a]))
a,b=map(int,input().split())
if a*b=0:print("Zero")
elif 0<a:print("Positive")
else:
  if -a%2==0:print("Positive")
  else:print("Negative")

### FIXED CODE ###

a,b=map(int,input().split())
if a*b<=0:print("Zero")
elif 0<a:print("Positive")
else:
  if (b-a)%2==1:print("Positive")
  else:print("Negative")
import math
from itertools import accumulate

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

L = [0]+list(accumulate(a, math.gcd))
R = list(accumulate(reversed(a), math.gcd))[::-1]+[0]

ans = 0

for i in range(n-1):
        ans = max(math.gcd(L[i],R[i+1]),ans)

print(L)
print(R)
print(ans)


### FIXED CODE ###

from fractions import gcd

n = int(input())
list_ = list(map(int, input().strip().split()))

gcd_from_left = [0]
gcd_from_right = [0]
for i in range(n):
    gcd_from_left.append(gcd(gcd_from_left[i], list_[i]))
    gcd_from_right.append(gcd(gcd_from_right[i], list_[-(i + 1)]))

gcd_from_left.insert(0, 0)
gcd_from_right.insert(0, 0)
gcd_from_right.reverse()

print(max(gcd(gcd_from_left[i], gcd_from_right[i]) for i in range(n + 2)))
for i1 in range(1, M+1):
    for i2 in range(i1, M+1):
        for i3 in range(i2, M+1):
            for i4 in range(i3, M+1):
                for i5 in range(i4, M+1):
                    for i6 in range(i5, M+1):
                        for i7 in range(i6, M+1):
                            for i8 in range(i7, M+1):
                                for i9 in range(i8, M+1):
                                    for i10 in range(i9, M+1):
                                        tmp = 0
                                        #添字の順番を合わせるために一つ目に0を代入している感じ。
                                        arrs = {0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10}
                                        for a, b, c, d in arr:
                                            if arrs[b] - arrs[a] == c:
                                                tmp += b
                                        ans = max(ans, tmp)
                            
print(ans)

### FIXED CODE ###

from itertools import *
n, m, q = map(int, input().split())

aaa = []
for i in range(1, m+1):
    aaa.append(i)
l = []
for i in range(q):
    a = list(map(int, input().split()))
    l.append(a)
    
a = list(combinations_with_replacement(aaa, n))
ans = 0

for i in a:
    aa = 0
    for j in l:
        if i[j[1]-1] - i[j[0]-1] == j[2]:
            aa+=j[3]
        if aa > ans:
            ans = aa
print(ans)
from collections import defaultdict
from operator import sub

def main():
    N = int(input())
    balls = [tuple(map(int,input().split())) for _ in range(N)]
    d = defaultdict(int)
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            d[tuple(map(sub, balls[i], balls[j]))] += 1
    mmax = max(d.values())
    mmax = int(N - mmax)
    try:
        print(mmax)
    except OSError:
        print(100)


if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import defaultdict
from operator import sub

def main():
    N = int(input())
    balls = [tuple(map(int,input().split())) for _ in range(N)]
    d = defaultdict(int)
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            d[tuple(map(sub, balls[i], balls[j]))] += 1
    try:
        mmax = N - max(d.values(), default=0)
        print(mmax)
    except ValueError:
        print(100)

if __name__ == '__main__':
    main()
x,y=map(int,input().split())
a=0
for i in range(x+1):
  if 2*i+4*(x-i)==y:
    a=1
    break
if a=1:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

x,y=map(int,input().split())
a=0
for i in range(x+1):
  if 2*i+4*(x-i)==y:
    a=1
    break
if a==1:
  print('Yes')
else:
  print('No')
t,x=int(input().split('  '))
print(t/x)

### FIXED CODE ###

# -*- coding: utf-8 -*-

t, x = map(int, input().split())

ans = t/x

print(ans)
s=list(input())
if s[0]==s[1] or s[0]==s[2] or s[1]==s[2]:
    print(″No″)
else:
    print(″Yes″)

### FIXED CODE ###

s=list(input())
if s[0]==s[1] or s[0]==s[2] or s[1]==s[2]:
    print("No")
else:
    print("Yes")
A = list(map(int, input().split(' ')))

L=A[0]+A[1]
R=A[2]+A[3]
if L<R: print("Right")
if L=R: print("Balanced")
if L>R: print("Left")

### FIXED CODE ###

A,B,C,D = input().split(' ')
A,B,C,D = [int(A),int(B),int(C),int(D)]

L= A + B
R = C + D

if L>R:
	print("Left")
elif L==R:
	print("Balanced")
else:
	print("Right")
from math import ceil
minutes = [int(input()) for _ in range(5)]

x = min([(x, x%10) for x in minutes if x%10 != 0], key=lambda x: x[1])

minutes.remove(x[0])
print(sum([ceil(x/10)*10 for x in minutes])+x[0])


### FIXED CODE ###

from math import ceil
minutes = [int(input()) for _ in range(5)]

arr = [(x, x%10) for x in minutes if x%10 != 0]
if arr:
    x = min(arr, key=lambda x: x[1])
    minutes.remove(x[0])
    print(sum([ceil(x/10)*10 for x in minutes])+x[0])
else:
    print(sum(minutes))
if a == b:
    print("Draw")
elif a > b and b != 1:
    print("Alice")
elif b == 1 and a > b:
    print("Bob")
elif a == 1 and b > a:
    print("Alice")
else:
    print("Bob")

### FIXED CODE ###

a,b = map(int,input().split())
if a == 1:
    a = 14
if b == 1:
    b = 14
if a == b:
    print("Draw")
elif a < b:
    print("Bob")
else:
    print("Alice")
n,k,q=map(int,input().split())
a=[k-q]*n
for i in range(q):
    point=int(input())
    a[point-1] += 1
for i in range(len(l)):
    if l[i] > 0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

n,k,q=map(int,input().split())
a=[k-q]*n
for i in range(q):
    point=int(input())
    a[point-1] += 1
for i in range(len(a)):
    if a[i] > 0:
        print("Yes")
    else:
        print("No")
K,N = map(int, input().split())
A = [int(N) for N in input().split()]
#print(A[0])
max1 = 0
max2 = 0
for i in range(0,N-1):
    max1 = A[i+1]-A[i]
    if max1>max2:
        max2=max1
if a[0]==0:
    lastlength = 20-A[N-1]
    if lastlength >max2:
        max2=lastlength
else:
    lastlength = A[N-1]-A[0]
    if lastlength>max2:
        max2=lastlength
print(20-max2)

### FIXED CODE ###

K,N = map(int, input().split())
A = [int(N) for N in input().split()]
#print(A[0])
max1 = 0
max2 = 0
for i in range(0,N-1):
    max1 = A[i+1]-A[i]
    if max1>max2:
        max2=max1
if A[0]==0:
    lastlength = K-A[N-1]
    if lastlength >max2:
        max2=lastlength
else:
    lastlength = K-A[N-1]+A[0]
    if lastlength>max2:
        max2=lastlength
print(K-max2)
import math
S = input()
K = int(input())
i = 0
while True:
    if S[i] == '1':
        if K == 1:
            break
        else:
            K-=1
            i+=1
    else:
        d = int(math.log(int(S[i]))*10**15)
        if d<K:K-=d
        else:break
        i += 1
print(S[i])

### FIXED CODE ###

S = input()
K = int(input())
i = 0
while True:
    if S[i] == '1':
        if K == 1:
            break
        else:
            K-=1
            i+=1
    else:
        break
print(S[i])
# encoding: utf-8
N, M = map(int, input().split())

# primes = [2, 3, 5, 7, 11, 13, 17]

# M_tmp = M
# factors = []
# for p in primes:
#     for i_p in range(32):
#         if M_tmp % (p ** (i_p + 1)) > 0: break
#     if i_p > 0: factors.append((p, i_p))
#     M_tmp = M_tmp // (p ** i_p)

## memo
memo = [[None] * 33 for i in range(N)] # max ip

def distribute(pos, full, tmp):
    # read memo
    if memo[pos][tmp] != None: return memo[pos][tmp]
    # end
    if tmp == 0: return 1
    # next
    ret = 0
    if pos < N - 1:
        for i in range(tmp + 1): ret += distribute(pos + 1, full, tmp - i)
    else: ret += 1
    # print("###", pos, tmp, ret)
    # write memo
    if memo[pos][tmp] != None: memo[pos][tmp] = ret
    return ret

# ans = 1
# for p, i_p in factors:
#     tmp = distribute(0, i_p, i_p)
#     ans = ans * tmp
#     # print("#", p, tmp)

M_tmp = M
ans = 1
for p in range(2, 2 ** 32):
    # how many times M_tmp can be divided
    for i_p in range(33):
        if M_tmp % (p ** (i_p + 1)) > 0: break
    # escape if M_tmp cannot be divided
    # print("#", p, i_p)
    if i_p < 1: continue
    # ans update (dp)
    ## search and count
    ans_tmp = distribute(0, i_p, i_p)
    # print("###", ans_tmp)
    ## add
    ans = (ans * ans_tmp) % (10 ** 9 + 7)
    # next
    M_tmp = M_tmp // (p ** i_p)
    if M_tmp == 1: break # oh...

print(ans)

### FIXED CODE ###

# encoding: utf-8
import math
N, M = map(int, input().split())

ips = []
M_tmp = M
for p in range(2, int(math.sqrt(M)) + 1):
    if M_tmp % p > 0: continue
    for i_p in range(1, 33):
        if M_tmp % (p ** (i_p + 1)) > 0: break
    ips.append(i_p)
    M_tmp = M_tmp // (p ** i_p)
    if M_tmp == 1: break
else:
    ips.append(1)

#### O(NlogM) below ?
# create memo
## init
if len(ips) > 0: ip_max = max(ips)
else: ip_max = 0
memo = [[None] * N for i in range(ip_max + 1)] # max ip
for j in range(N): memo[0][j] = 1
for i in range(1, ip_max + 1): memo[i][N - 1] = 1
## fill
for i in range(1, ip_max + 1):
    sum_tmp = 0
    vals = list(memo[i - 1])[::-1]
    ptr_memo = memo[i]
    for j, val in enumerate(vals):
        sum_tmp += val
        ptr_memo[N - 1 - j] = sum_tmp
#### O(NlogM) above ?
        
# calculate ans
ans = 1
for i_p in ips:
    ans = (ans * memo[i_p][0]) % (10 ** 9 + 7)

if M == 1: print(1)
elif ip_max < 1: print(N)
else: print(ans)
orint("A"+input()[8]+"C")

### FIXED CODE ###

print("A"+input()[8]+"C")
n=int(input())
a=list(map(int,input().split()))
print(*a[-1::-2],*a[n%2::2])

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
print(*a[-1::-2]+a[n%2::2])
N,K=map(int,input().split())
N=list(map(int,input().split()))
a={}
 
b=1
a[1]=1
count=0
while(count<=K+1):
  count+=1
  b=N[b-1]
  #print(b)
  if b in a:
    #print(a)
    #print(b)
    #print(count)
    cycle=count-a[b]
    rest=K-count+1
    ans=rest%cycle
    for i in range(ans-1):
      b=N[b-1]
      count+=1
      if count==K+1:
        break
    print(b)
    break
  a[b]=count
  if count==K+1:
    print(b)
    break

### FIXED CODE ###

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

count=0
k=1
countlist={}
#countlist[1]=A[0]
count=1
while True:    
    k=A[k-1]
    
    if k in countlist:
        cycle=count-countlist[k]
        rest=K-count
        move=rest%cycle
        for i in range(min(rest,move)):
            k=A[k-1]
        print(k)
        break
    
    countlist[k]=count
    
    if count==K:
        print(k)
        break
    
    count+=1
a,b = map(int, input())
print((a+b)%24)

### FIXED CODE ###

a,b = map(int, input().split())
print((a+b)%24)
import math
N = int(input())
print(math.factorial(N)-math.factorial(N)/(10**9+7)*math.factorial(N))

### FIXED CODE ###

import math
N = int(input())
print(math.factorial(N) % (10**9+7))
n=int(input())
a=list(map(int,input().split()))

def dp(i,n,a):
	if i==(n-1):
		return 0
	d1=1e10
	d2=1e10
	if(i+1<=n-1):
		d1=dp(i+1,n,a)+abs(a[i]-a[i+1])
	if(i+2<=n-1):
		d2=dp(i+2,n,a)+abs(a[i]-a[i+2])
	return min(d1,d2)

print(dp(0,n,a))


### FIXED CODE ###

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

dp = [0]*n
for i in range(1,n):
	if i == 1:
		dp[i]=abs(a[0]-a[1])
	else:
		dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]))
print(dp[n-1])
imput_list = list(map(int,input().split()))
print(math.floor(math.log(imput_list[1]/imput_list[0], 2)) + 1)

### FIXED CODE ###

input_list = list(map(int,input().split()))
for i in range(61):
    if (input_list[0]*(2**i )<=input_list[1])&(input_list[0]*(2**(i +1))>input_list[1]):
        print(i+1)
import math
N = input()
print(N*math.pi)

### FIXED CODE ###

import math
N = input()
M = 2*float(N)*math.pi
print(M)
n = int(input())
a = list(map(int, input().split()))

b = [0] + a + [0]
c = []
for i in range(n+1):
    c.append(abs(b[i] - b[i+1]))

for i in range(n):
    ans = l - c[i] - c[i+1]
    ans += abs(b[i] - b[i+2])
    print(ans)


### FIXED CODE ###

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

b = [0] + a + [0]
c = []
for i in range(n+1):
    c.append(abs(b[i] - b[i+1]))

l = sum(c)

for i in range(n):
    ans = l - c[i] - c[i+1]
    ans += abs(b[i] - b[i+2])
    print(ans)
N-int(input())
print(N//3)

### FIXED CODE ###

N=int(input())
print(N//3)
n=int(input())
s=list(map(int,input().split()))
l=[0 for _ in range(12)]
for x in s:
    l[x//400]+=1
j=sum(r>0 for r in l[:8])
print(j,j+sum(l[8:]))

### FIXED CODE ###

n=int(input())
s=list(map(int,input().split()))
l=[0 for _ in range(13)]
for x in s:
    l[x//400]+=1
j=sum(r>0 for r in l[:8])
print(max(1,j),j+sum(l[8:]))
ab = inpout()
a, b = ab.split("")
A = int(a)
B = int(b)

if "0" in a or "0" in b:
	print(-1)
else:
	print(A * B)

### FIXED CODE ###

ab = input()
a, b = ab.split(" ")
A = int(a)
B = int(b)

if "0" in a or "0" in b or A > 9 or B > 9:
    print(-1)
else:
    print(A * B)
import * from numpy;i=int32;p=input;q=searchsorted;N=int(p());A=i(p().split());B=i(p().split());c=0;
for k in range(1,30):
  a,b=sort(hstack((A%(1<<k),A%(1<<k)-2**k))),B%(1<<k);c+=(sum(q(a,2**k-b)-q(a,2**(k-1)-b)))%2*2**(k-1)
print(c)


### FIXED CODE ###

#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n = II()
    ab = LIR(n)
    cd = LIR(n)
    ab.sort()
    cd.sort()
    check = [0 for i in range(n)]
    ans = 0
    #print(ab)
    for i, c in enumerate(cd):
        d = c[1]
        c = c[0]
        maxy = -1
        x = -1
        for k, a in enumerate(ab):
            b = a[1]
            a = a[0]
            if maxy < b and c > a and check[k] == 0 and d > b:
                maxy = b
                x = k
                #print(a,b,c,d)
        if x != -1:
            ans += 1
            check[x] += 1
    print(ans)


    return

#D
def D():
    N = II()
    a = LI()
    b = LI()
    ans = 0
    for i in range(29):
        t = 2 ** i
        a2 = [A % (2 * t) for A in a]
        b2 = [B % (2 * t) for B in b]
        a2.sort()
        b2.sort()
        ansb = 0
        r1 = r2 = r3 = 0
        for A in reversed(a2):
            while r1 < N and A + b2[r1] < t:
                r1 += 1
            while r2 < N and A + b2[r2] < 2*t:
                r2 += 1
            while r3 < N and A + b2[r3] < 3*t:
                r3 += 1
            ansb += (r2 - r1) + (N - r3)
        ans += ((ansb %2 ) << i)
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    D()
#!/usr/bin/env python
# -*- coding: utf-8 -*-

al = [0, 5] + [0] * 49
bl = [0, 3] + [0] * 49


def solve2(ans, x, idx, cnt):
    if idx == 1:
        return ans + (0, 0, 1, 2, 3, 3, 3)[x] + [0, 1][cnt >= 1]
    if x == (al[idx] // 2) + 1:
        return ans + bl[idx - 1] + 1 + [0, 1][cnt >= 1]
    elif x > (al[idx] // 2) + 1:
        ans += bl[idx - 1]
        x -= (al[idx] // 2)
        cnt += 1
    return solve2(ans, x, idx - 1, cnt)


def solve():
    n, x = map(int, input().split())
    for i in range(2, n + 1):
        al[i] = al[i - 1] * 2 + 3
        bl[i] = bl[i - 1] * 2 + 1
    ans = solve2(0, x, n, 0)
    print(ans)


if __name__ == "__main__":
    solve()


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

al = [0, 5] + [0] * 49
bl = [0, 3] + [0] * 49


def solve2(ans, x, idx, cnt):
    if idx == 1:
        if x >= 5:
            return ans + 3
        return ans + (0, 0, 1, 2, 3, 3)[x]
    if x >= al[idx - 1] + 1:
        ans += bl[idx - 1]
        x -= al[idx - 1] + 1
        if x >= 1:
            ans += 1
            x -= 1
    else:
        x -= 1
        if x <= 0:
            return ans
    return solve2(ans, x, idx - 1, cnt)


def solve(n, x):
    for i in range(2, n + 1):
        al[i] = al[i - 1] * 2 + 3
        bl[i] = bl[i - 1] * 2 + 1
    ans = solve2(0, x, n, 0)
    print(ans)


if __name__ == "__main__":
    n, x = map(int, input().split())
    solve(n, x)
import sys
input = sys.stdin.readline
from bisect import *

def dfs(v, pv):
    j = bisect_left(dp, a[v])
    prev = dp[j]
    dp[j] = a[v]
    ans[v] = bisect_left(dp, 10**18)-1
    
    for nv in G[v]:
        if nv==pv:
            continue
        
        dfs(nv, v)
    
    dp[j] = prev

N = int(input())
a = list(map(int, input().split()))
G = [[] for _ in range(N)]

for _ in range(N-1):
    u, v = map(int, input().split())
    G[u-1].append(v-1)
    G[v-1].append(u-1)

dp = [10**18]*(N+1)
dp[0] = -10**18
ans = [-1]*N
dfs(0, -1)

for ans_i in ans:
    print(ans_i)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(2*10**5+100)
from bisect import *

def dfs(v, pv):
    j = bisect_left(dp, a[v])
    prev = dp[j]
    dp[j] = a[v]
    ans[v] = bisect_left(dp, 10**18)-1
    
    for nv in G[v]:
        if nv==pv:
            continue
        
        dfs(nv, v)
    
    dp[j] = prev

N = int(input())
a = list(map(int, input().split()))
G = [[] for _ in range(N)]

for _ in range(N-1):
    u, v = map(int, input().split())
    G[u-1].append(v-1)
    G[v-1].append(u-1)

dp = [10**18]*(N+1)
dp[0] = -10**18
ans = [-1]*N
dfs(0, -1)

for ans_i in ans:
    print(ans_i)
n=str(N)
if n.find("7")!=-1
   print("Yes")
else 
   print("No")

### FIXED CODE ###

n=str(input())
if n.find("7")!= -1:
   print("Yes")
else:
   print("No")
N, A, B = map(int, input().split())

counter = [0 for _ in range(N)]
ans = 0

for i in range(N):
    string = str(i)
    for j in range(len(string)):
        counter[i] += string[j]

for i in range(N):
  if(counter[i]<=B and counter[i]>=A):
    ans += i

print(ans)

### FIXED CODE ###

N, A, B = map(int, input().split())
ans = 0

for i in range(1, N+1):
    num_sum = 0
    for j in str(i):
        num_sum += int(j)
    if A<= num_sum <= B:
        ans += i

print(ans)
s = input()
t = 0
ans =''
while t <= len(s):
  ans += s[t]
  t += 2
print(ans)

### FIXED CODE ###

s = input()
n = len(s)
ans =''
i = 0
while i < n:
  ans += s[i]
  i += 2
print(ans)
# AGC023
import collections
from scipy.special import comb
N = int(input())
A = list(map(int, input().split()))
ans = 0
S = [0] * (N+1)
for i in range(N):
    S[i+1] = S[i] + A[i]
c = collections.Counter(S)
c = c.most_common()
for i in range(len(c)):
    if c[i][1] == 1:
        pass
    if c[i][1] == 2:
        ans += 1
    else:
        ans += comb(c[i][1], 2)
print(int(ans))

### FIXED CODE ###

# AGC023
import collections
N = int(input())
A = list(map(int, input().split()))
ans = 0
S = [0] * (N+1)
for i in range(N):
    S[i+1] = S[i] + A[i]
c = collections.Counter(S)
c = c.most_common()
for i in range(len(c)):
    tmp = c[i][1]
    if tmp == 1:
        pass
    else:
        ans += tmp*(tmp-1) // 2
print(int(ans))
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
s = [0] * n
for i in sc:
    s[i[0]-1] = str(i[1])
ans = ""
first = True
for i in s:
    if i == 0 and first and len(s) != 1:
        ans += str(1)
        first = False
        continue
    ans += str(i)
if len(ans) != 1 and len(str(int(s))):
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
if n == 3:
    l = range(100, 1000)
if n == 2:
    l = range(10, 100)
if n == 1:
    l = range(0, 10)
flag = False
for i in l:
    num = str(i)
    if all([num[s-1] == str(c) for s, c in sc]):
        #print(num)
        #exit()
        flag = True
        ans = num
        break
if flag:
    print(num)
else:
    print(-1)
#print(-1)
n, q = input().split(" ")
n = int(n)
q = int(q)

list_ab = []
for i in range(n - 1):
  pair_ab = [int(num) for num in input().split(" ")]
  list_ab.append(pair_ab)

list_px = []
for i in range(q):
  pair_px = [int(num) for num in input().split(" ")]
  list_px.append(pair_px)

def make_dict(list_ab):
  dict = {}
  for num in range(1, n+1):
    dict[num] = []
  for pair_ab in list_ab:
    dict[int(pair_ab[0])].append(pair_ab[1])
  return dict

ab_dict = make_dict(list_ab)

counter = [0]*(n+1)

def calc(position, num_plus):
  counter[position] += num_plus
  list_plus = ab_dict[position]
  for num in list_plus:
    calc(num, num_plus)

for p, x in list_px:
  calc(p, x)

for i in range(1, len(counter)):
  counter[i] = str(counter[i])
counter.pop(0)
str = " ".join(counter)
print(str)


### FIXED CODE ###

from collections import defaultdict as dd
n, q = map(int, input().split())
Connections = dd(list)
for i in range(n-1):
    a, b = map(int, input().split())
    Connections[a].append(b)
    Connections[b].append(a)

#Tree[node] -> children(list)
Tree = dd(list)
visited = set()
stack = [1]
while stack != []:
    temp = []
    for taregt_node in stack:
        for next_node in Connections[taregt_node]:
            if next_node not in visited:
                Tree[taregt_node].append(next_node)
                visited.add(taregt_node)
                temp.append(next_node)
    stack = temp
#print(Tree)

#Point[node] -> point
Point = dd(int)
for i in range(q):
    p, x = map(int, input().split())
    Point[p] += x
#print(Point)

Counter = dd(int)
#visited = set()
stack = [1]
Counter[1] = Point[1]
while stack != []:
    temp = []
    for target_node in stack:
        for next_node in Tree[target_node]:
            Counter[next_node] = Counter[target_node] + Point[next_node]
            temp.append(next_node)
    stack = temp
#print(Counter)

for i in range(1, n):
    print(Counter[i], end=" ")
print(Counter[n])
import math
X, Y = map(int, input().split())

MOD = 10 ** 9 + 7

xx = 2 * Y - X
if (xx % 3 == 0 and Y - 2 * xx // 3 >= 0):
    a = xx // 3
    b = Y - 2 * a

    f = 1
    factorials = [1]
    for m in range(1, a + b + 1):
        f *= m
        f %= MOD
        factorials.append(f)

    print (a, b)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (a + b + 1)
    invs[a + b] = inv
    for m in range(a + b, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv


    print (factorials[-1] * invs[a] * invs[b] % MOD)

    # print (math.factorial(a + b) // math.factorial(a) // math.factorial(b) %  MOD)


else:
    print (0)


### FIXED CODE ###

import math
X, Y = map(int, input().split())

MOD = 10 ** 9 + 7

xx = 2 * Y - X
if (xx >= 0 and xx % 3 == 0 and Y - 2 * xx // 3 >= 0):
    a = xx // 3
    b = Y - 2 * a

    f = 1
    factorials = [1]
    for m in range(1, a + b + 1):
        f *= m
        f %= MOD
        factorials.append(f)

    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (a + b + 1)
    invs[a + b] = inv
    for m in range(a + b, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv


    print (factorials[-1] * invs[a] * invs[b] % MOD)

    # print (math.factorial(a + b) // math.factorial(a) // math.factorial(b) %  MOD)


else:
    print (0)