Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N = int(input())
D_list = list(map(int,input().split()))
M = int(input())
T_list = list(map(int,input().split()))

ans = 'YES'
for i in T_list:
    if not D_list.count(i) >= T_list.count(i):
        ans = 'NO'
        print(ans)
        break
if ans == 'YES':
    print(ans)




### FIXED CODE ###

N = int(input())
D_list = list(map(int, input().split()))
M = int(input())
T_list = list(map(int, input().split()))

dic_T = {}
for i in T_list:
    if i in dic_T:
        dic_T[i] += 1
    else:
        dic_T[i] = 1

dic_D = {}
for i in D_list:
    if i in dic_D:
        dic_D[i] += 1
    else:
        dic_D[i] = 1

for i in dic_T:
    if i in dic_D:
        if not dic_T[i] <= dic_D[i]:
            print('NO')
            exit()
    else:
        print('NO')
        exit()

print('YES')
### BUGGY CODE ###

import itertools

N = int(input())
S = input()
D = 10**9+7

d = {}
for i,n in enumerate(S):
    if n in d.keys():
        d[n] += 1
    else:
        d[n] = 1

count = 0
for i in range(1,len(d.keys())+1):
    for p in list(itertools.combinations(d.keys(),i)):
        tmp = 1
        for c in p:
            tmp *= d[c]
        count += tmp
print(count%D)

### FIXED CODE ###

N = int(input())
S = input()
D = 10**9+7

d = {}
for i,n in enumerate(S):
    if n in d.keys():
        d[n] += 1
    else:
        d[n] = 1

ans = 1
for i in d.values():
    ans *= i+1
print((ans-1)%D)
### BUGGY CODE ###

H, W = map(int, input().split())
cnt = [[0] * W for _ in range(H)]
S = [list(input()) for _ in range(H)]

for i in range(H):
    done = [0] * W
    for j in range(W):
        if S[i][j] == '#':
            continue
        if done[j]:
            continue
        l = 0
        while j + l < W:
            if S[i][j+l] == '#':
                break
            l += 1
        for k in range(l):
            cnt[i][j+k] += l
            done[j+k] = 1

for j in range(W):
    done = [0] * H
    for i in range(H):
        if S[i][j] == '#':
            continue
        if done[i]:
            continue
        l = 0
        while i + l < H:
            if S[i+l][j] == '#':
                break
            l += 1
        for k in range(l):
            cnt[i+k][j] += l
            done[i+k] = 1
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, cnt[i][j]-1)
print(ans)

### FIXED CODE ###

H, W = map(int, input().split())
cnt = [[0] * W for _ in range(H)]
S = [list(input()) for _ in range(H)]

for i in range(H):
    done = [0] * W
    for j in range(W):
        if S[i][j] == '#':
            continue
        if done[j]:
            continue
        l = 0
        while j + l < W:
            if S[i][j+l] == '#':
                break
            l += 1
        for k in range(l):
            cnt[i][j+k] += l
            done[j+k] = 1

for j in range(W):
    done = [0] * H
    for i in range(H):
        if S[i][j] == '#':
            continue
        if done[i]:
            continue
        l = 0
        while i + l < H:
            if S[i+l][j] == '#':
                break
            l += 1
        for k in range(l):
            cnt[i+k][j] += l
            done[i+k] = 1
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, cnt[i][j]-1)
print(ans)
### BUGGY CODE ###

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

def grouping_values(list_):
    res = dict()
    for v in list_:
        if v not in res:
            res[v] = [v]
            continue
        res[v].append(v)
    return res

def comb2(list_):
    leng = len(list_)
    if leng == 1:
        return 0
    return (leng*(leng-1)) // 2

grouped = grouping_values(A)

ans1 = dict()
for k in grouped:
    ans1[k] = comb2(grouped[k])

ans2 = dict()
for k in grouped:
    grouped_ = grouped[k][1:]
    ans2[k] = comb2(grouped_)

for a in A:
    x = 0
    for k in ans1:
        if k == a:
            continue
        x += ans1[k]
    print(x + ans2[a])



### FIXED CODE ###

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

def group_by_val(list_):
    res = dict()
    for v in list_:
        if v not in res:
            res[v] = [v]
            continue
        res[v].append(v)
    return res

def count_leng(dict_):
    res = dict()
    for k in dict_:
        res[k] = len(dict_[k])
    return res

def comb2(list_):
    leng = len(list_)
    if leng == 1:
        return 0
    return (leng*(leng-1)) // 2

grouped_dict = group_by_val(A)
group_leng = count_leng(grouped_dict)

sum_val = 0
for k in grouped_dict:
    sum_val += comb2(grouped_dict[k])

for a in A:
    print(sum_val-(group_leng[a]-1))
### BUGGY CODE ###

# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
from heapq import heappop, heappush
#from collections import defaultdict
# import math
# from itertools import product, accumulate, combinations, product
# import bisect# lower_bound etc
import numpy as np
# from copy import deepcopy
#from collections import deque
#import numba
#import math

def run():
    N = int(input())
    A = list(map(int, sysread().split()))
    NN = 10 ** 6 + 1
    A = sorted(A)
    checks = np.array([True] * NN)
    ret = 0
    for i, a in enumerate(A[:-1]):
        if checks[a] and a != A[i+1]:
            ret += 1
        checks[a:NN+1:a] = False
    if checks[A[-1]]:
        ret += 1


    print(ret)

if __name__ == "__main__":
    run()

### FIXED CODE ###

# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
from heapq import heappop, heappush
#from collections import defaultdict
# import math
# from itertools import product, accumulate, combinations, product
# import bisect# lower_bound etc
import numpy as np
# from copy import deepcopy
#from collections import deque

#import numba
#import math

def run():
    N = int(input())
    A = list(map(int, sysread().split()))
    NN = 10 ** 6 + 1
    A = sorted(A)
    checks = np.array([True] * NN)
    ret = 0
    for i, a in enumerate(A[:-1]):
        if checks[a] and a != A[i+1]:
            ret += 1
        if checks[a]:
            checks[a:NN+1:a] = False
    if checks[A[-1]]:
        ret += 1


    print(ret)

if __name__ == "__main__":
    run()
### BUGGY CODE ###

x = list(map(int,input().split()))
count=0
for a in range(max(0,x[1]-2*x[0]),min(x[0],x[1])+1):
    for b in range(max(0,x[1]-a-x[0]),min(x[0],x[1]-a)+1):
        for c in range(max(x[1]-a-b,0),min(x[1]-a-b,x[0])+1):
            if(a+b+c==x[1]):
                count+=1
print(count)

### FIXED CODE ###

x = list(map(int,input().split()))
count=0
for a in range(max(0,x[1]-2*x[0]),min(x[0],x[1])+1):
    for b in range(max(0,x[1]-a-x[0]),min(x[0],x[1]-a)+1):
        for c in range(max(x[1]-a-b,0),min(x[1]-a-b,x[0])+1):
            if(a+b+c==x[1]):
                count+=1
print(count)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def check(N, S, a, b):
    nS = [[S[(i+a)%N][(j+b)%N] for j in range(N)] for i in range(N)]
    return all(all(e==te for e, te in zip(l, tl)) for l, tl in zip(nS, zip(*nS)))

def solve(N: int, S: "List[str]"):
    ans = 0
    for a in range(N):
        if check(N, S, a, 0):
            ans += N
    return ans

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    print(solve(N, S))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import numpy as np

def gen_check(N: int, S: "List[str]"):
    tmp = [tuple(s)+tuple(s) for s in S]
    S = np.array(tmp+tmp)
    def check(a, b):
        s = S[a:a+N,b:b+N]
        return np.array_equal(s, s.T)
    return check

def solve(N: int, S: "List[str]"):
    ans = 0
    check = gen_check(N, S)
    for a in range(N):
        if check(a, 0):
            ans += N
    return ans

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    print(solve(N, S))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()
### BUGGY CODE ###

import bisect
N = int(input())
*A, = map(int, input().split())
A.sort()
a = []
b = []
last = 0
for i in range(N):
    if last != A[i]:
        a.append([A[i], 0])
        b.append(A[i])
        last = A[i]
    a[-1][1] += 1

ans = 0
for n, c in a:
    if c == 1:
        r = bisect.bisect_right(b, n//2)
        ok = True
        for i in range(r):
            if n % b[i] == 0:
                ok = False
                break
        if ok:
            ans += 1
print(ans)


### FIXED CODE ###

from collections import Counter
N = int(input())
*A, = map(int, input().split())
A.sort()
c = Counter(A)
ans = 0
d = [0]*(10**6+1)
for i in range(N):
    if d[A[i]] == 0:
        if c[A[i]] == 1:
            ans += 1
        j = A[i]
        while j <= (10**6):
            d[j] += 1
            j += A[i]
print(ans)
### BUGGY CODE ###

import sys
from itertools import permutations


def input():
    return sys.stdin.readline().strip()


def main():
    N, M, R = map(int, input().split())

    def warshall_floyd(d):
        # d[i][j]: iからjへの最短距離
        for k in range(N):
            for i in range(N):
                for j in range(N):
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j])
        return d

    r = list(map(int, input().split()))
    d = [[float("inf")] * N for i in range(N)]
    for i in range(M):
        x, y, z = map(int, input().split())
        d[x - 1][y - 1] = z
        d[y - 1][x - 1] = z
    for i in range(N):
        d[i][i] = 0  # 自身のところに行くコストは０
    D = warshall_floyd(d)
    P = list(permutations(r))
    cost = float("inf")
    for p in P:
        c = 0
        for i in range(R - 1):
            c += D[p[i] - 1][p[i + 1] - 1]
        if c < cost:
            cost = c
    print(cost)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from itertools import permutations


def input():
    return sys.stdin.readline().strip()


def main():
    N, M, R = map(int, input().split())

    def warshall_floyd(d):
        # d[i][j]: iからjへの最短距離
        for k in range(N):
            for i in range(N):
                for j in range(N):
                    tmp = d[i][k] + d[k][j]
                    if d[i][j] > tmp:
                        d[i][j] = tmp
        return d

    r = list(map(int, input().split()))
    d = [[float("inf")] * N for i in range(N)]
    for i in range(M):
        x, y, z = map(int, input().split())
        d[x - 1][y - 1] = z
        d[y - 1][x - 1] = z
    for i in range(N):
        d[i][i] = 0  # 自身のところに行くコストは０
    D = warshall_floyd(d)
    P = list(permutations(r))
    cost = float("inf")
    for p in P:
        c = 0
        for i in range(R - 1):
            c += D[p[i] - 1][p[i + 1] - 1]
        if c < cost:
            cost = c
    print(cost)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

N = int(input())

XY = [[set() for i in range(10**5+1)] for j in range(2)]
for i in range(N):
  x, y = map(int, input().split())
  XY[0][x].add(y)
  XY[1][y].add(x)

is_visited_x = [False] * (10**5 + 1)
def dfs(x):
  global is_visited_x
  is_visited_x[x] = True
  stack = [[x], []]
  idx = 0
  num_e = 0
  num_xy = [1, 0]
  parent = 0
  while stack[0] or stack[1]:
    node = stack[idx][-1]
    children = XY[idx][node]
    if children:
      child = children.pop()
      XY[idx-1][child].remove(node) # 今来た道を削除
      num_e += 1
      if child in stack[idx-1]:
        continue
      stack[idx-1].append(child)
      num_xy[idx-1] += 1
      is_visited_x[child] += idx
      idx = (idx + 1) % 2
    else:
      stack[idx].pop()
      idx = (idx + 1) % 2
  return num_e, num_xy

ans = 0
for x in range(1, 10**5+1):
  if is_visited_x[x]:
    continue
  num_e, num_xy = dfs(x)
  ans += num_xy[0]*num_xy[1] - num_e

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
XY = [[set() for i in range(10**5+1)] for j in range(2)]
for i in range(N):
  x, y = map(int, input().split())
  XY[0][x].add(y)
  XY[1][y].add(x)

is_visited_x = [False] * (10**5 + 1)
def dfs(x):
  global is_visited_x
  is_visited_x[x] = True
  stack = [[x], []]
  idx = 0
  num_e = 0
  num_xy = [1, 0]
  parent = 0
  while stack[0] or stack[1]:
    node = stack[idx][-1]
    children = XY[idx][node]
    if children:
      child = children.pop()
      XY[idx-1][child].remove(node) # 今来た道を削除
      num_e += 1
      if child in stack[idx-1]:
        continue
      stack[idx-1].append(child)
      num_xy[idx-1] += 1
      is_visited_x[child] += idx
      idx = (idx + 1) % 2
    else:
      stack[idx].pop()
      idx = (idx + 1) % 2
  return num_e, num_xy

ans = 0
for x in range(1, 10**5+1):
  if is_visited_x[x]:
    continue
  num_e, num_xy = dfs(x)
  ans += num_xy[0]*num_xy[1] - num_e

print(ans)
### BUGGY CODE ###

n = int(input())
g = {}
for i in range(1,n+1):
    g[i] = []
for _ in range(n-1):
    a,b,c = map(int,input().split())
    g[a].append([b,c])
    g[b].append([a,c])
Q,k = map(int,input().split())
q = [list(map(int,input().split())) for _ in range(Q)]
from collections import deque
queue = deque(g[k])
shortest = [0]*(n+1)
while queue:
    a,c = queue.popleft()
    shortest[a] = c
    for v in g[a]:
        if shortest[v[0]]==0:
            queue.append([v[0],v[1]+c])
for x,y in q:
    print(shortest[x]+shortest[y])

### FIXED CODE ###

n = int(input())
g = {}
from collections import deque
for i in range(1,n+1):
    g[i] = deque([])
for _ in range(n-1):
    a,b,c = map(int,input().split())
    g[a].appendleft([b,c])
    g[b].appendleft([a,c])
Q,k = map(int,input().split())
q = [list(map(int,input().split())) for _ in range(Q)]
queue = deque(g[k])
shortest = [0]*(n+1)
while queue:
    a,c = queue.pop()
    shortest[a] = c
    while g[a]:
        v = g[a].pop()
        if shortest[v[0]]==0:
            queue.appendleft([v[0],v[1]+c])
for x,y in q:
    print(shortest[x]+shortest[y])
### BUGGY CODE ###

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

n = int(input())
l = [int(i) for i in input().split()]
l.sort()

count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k] + l[i] > l[j]:
                count += 1
            else:
                break

print(count)


### FIXED CODE ###

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

import bisect

n = int(input())
l = [int(i) for i in input().split()]
l.sort() # 二分探索するために整列

# l[i]+l[j]>l[x]を満たすxは
# 昇順に整列した配列を使うと
# 固定した2本の次のインデックスから必ず連続している
# そのため条件を満たす最大のxを二分探索で求めれば良い

count = 0
# 2本を固定して
for i in range(n-2):
    for j in range(i+1, n-1):
        # 3本目を探索
        index = bisect.bisect_left(l, l[i]+l[j])
        count += index - (j+1)

print(count)
### BUGGY CODE ###

n = int(input())

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

total = 0
mod = 1000000007

for i in range(0,n-1):
    for x in range(i+1,n):
        seki = list1[i] * list1[x] % mod
        total += seki



kotae = total % mod

print(kotae)


### FIXED CODE ###

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

mod = 10 ** 9 + 7
total = 0
y = sum(list1)

for i in range(0,n-1):
    y = y- list1[i]
    total += list1[i] * y % mod

total = total % mod
print(total)
### BUGGY CODE ###

n = int(input())
s = input()

def next(s):
  if s == '':  # empty
    return 0, 0, None
  if len(s) == s.count('#') or len(s) == s.count('.'):  # . or # only
    return s.count('#'), s.count('.'), None

  l = s.index('#')
  try:
    c = s.index('#.')+1
    try:
      r = s.index('.#')+1
    except:
      r = len(s)-1
  except:
    c,r = len(s)-1
  b = c - l
  w = r - c
  return b, w, s[r:]

black, white = 0, 0
if n == s.count('#') or n == s.count('.'):  # . or # only
  black += s.count('#')
  white += s.count('.')
  s = None
else:
  if s[0] == '.':
    s = s[s.index('.#')+1:]
while(s != None):
  b, w, s = next(s)
  black += b
  white += w
print(min(black, white))

### FIXED CODE ###

n = int(input())
s = '.'+input()
lb, rw = 0, s.count('.')-1
ans = lb+rw
for i in range(1,n+1):
  if s[i] == '#':
    lb += 1
  elif s[i] == '.':
    rw -= 1
  if lb+rw < ans:
    ans = lb+rw
print(ans)
### BUGGY CODE ###

from functools import lru_cache
from sys import stdin


@lru_cache(maxsize=None)
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def mygcd(lst):
    result = lst[0]
    for x in lst[1:]:
        result = gcd(result, x)
    return result


def main():
    _ = int(stdin.readline().rstrip())
    As = [int(x) for x in stdin.readline().rstrip().split()]
    max_ = 0
    for a in As:
        tmp = As[:]
        tmp.remove(a)
        max_ = max(max_, mygcd(tmp))
    print(max_)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from functools import lru_cache
from sys import stdin


@lru_cache(maxsize=None)
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def make_acc_gdbs(As):
    result = []
    tmp = 0
    for x in As:
        tmp = gcd(tmp, x)
        result.append(tmp)
    return result


def main():
    N = int(stdin.readline().rstrip())
    As = [int(x) for x in stdin.readline().rstrip().split()]
    lAs = make_acc_gdbs(As)
    rAs = make_acc_gdbs(As[::-1])[::-1]
    max_ = 0
    for i in range(N):
        left = 0 if i == 0 else lAs[i - 1]
        right = 0 if i == (N - 1) else rAs[i + 1]
        max_ = max(max_, gcd(left, right))
    print(max_)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

n,m = map(int,input().split())
l = [input().split() for _ in range(m)]
 
o = [l[i][0] for i in range(m)]
p = list(set(o))

t = 0
f = 0
 
for i in p:
  q = [l[j][1] for j in range(m) if l[j][0] == i ]
  if q.count("AC") == 0:
    pass
  else:
    t = t + 1
    f = f + q.index("AC")
print(t,f)

### FIXED CODE ###

n,m=map(int,input().split())
l=[0]*(n+1)
p=0
for _ in range(m):
  a,b=list(input().split())
  if str(b)=="AC" and l[int(a)]!=-1:
    p+=l[int(a)]
    l[int(a)]=-1
  elif str(b)=="WA" and l[int(a)]!=-1:
    l[int(a)]+=1
print(l.count(-1),p)
### BUGGY CODE ###

from heapq import nlargest
x,y,z,k=map(int,input().split())
A,B,C=[list(map(int,input().split()))for _ in[0]*3]
E=nlargest(k,(a+b+c for a in A for b in B for c in C))
for i in E:
    print(i)


### FIXED CODE ###

from heapq import nlargest
x,y,z,k=map(int,input().split())
A,B,C=[list(map(int,input().split()))for _ in[0]*3]
D=nlargest(k,(a+b for a in A for b in B ))
E=nlargest(k,(d+c for c in C for d in D ))
for i in E:
    print(i)
### BUGGY CODE ###

def Gcd(a, b):#ユークリッド互除法
	return Gcd(b, a % b) if b else a

N,M = map(int,input().split())
S = input()
T = input()

#最小公倍数
p = (N * M) // Gcd(N, M)
re = p

for i in range(p):
	#交差点
	if i % (p//N) == 0 and i % (p//M) == 0:
		#異なる文字
		if S[i // (p//N)] != T[i // (p//M)]:
			re = -1
			break
print(re)

### FIXED CODE ###

def Gcd(a, b):#ユークリッド互除法
	return Gcd(b, a % b) if b else a

N,M = map(int,input().split())
S = input()
T = input()

#最小公倍数
p = (N * M) // Gcd(N, M)
re = p

for i in range(0,p,max((p//N),(p//M))):
	#交差点
	if i % (p//N) == 0 and i % (p//M) == 0:
		#異なる文字
		if S[i // (p//N)] != T[i // (p//M)]:
			re = -1
			break
print(re)
### BUGGY CODE ###

N, Q = map(int, input().split())

S = input()
outputs = []
for i in range(Q):
    l, r = map(int, input().split())
    count = 0
    for j in range(l-1, r-1):
        if S[j] =="A" and S[j+1] == "C":
            count += 1
    outputs.append(count)

for i in outputs:
    print(i)


### FIXED CODE ###


N, Q = map(int, input().split())

S = input()
cumurative_sum_lst = [0]*(N+1)
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        cumurative_sum_lst[i+1] = cumurative_sum_lst[i] + 1
    else:
        cumurative_sum_lst[i+1] = cumurative_sum_lst[i]

outputs = []
for i in range(Q):
    l, r = map(int, input().split())
    l, r = l - 1, r - 1

    tmp = cumurative_sum_lst[r] - cumurative_sum_lst[l]
    outputs.append(int(tmp))

for i in outputs:
    print(i)
### BUGGY CODE ###


NQ = input().split(' ')
N = int(NQ[0])
Q = int(NQ[1])

tree_dict = {
    N: {
        'count': 0,
        'has_trees': []
    }
}

def f(p,x):
    tree_dict[p]['count'] += x
    for num in tree_dict[p]['has_trees']:
        f(num,x)

candidate_list = []

#Make tree dict
for _ in range(N-1):
    ab = input().split(' ')
    a = int(ab[0])
    b = int(ab[1])
    candidate_list.append((a,b))

candidate_list.reverse()

for candidate in candidate_list:

    a = candidate[0]
    b = candidate[1]
    if b not in tree_dict.keys():
        tree_dict[b] = {
                'count': 0,
                'has_trees': []
            }

    if a not in tree_dict.keys():
        tree_dict[a] = {
                'count': 0,
                'has_trees': tree_dict[b]['has_trees'] + [b]
            }
    else:
        tree_dict[a]['has_trees'] += tree_dict[b]['has_trees'] + [b]

for _ in range(Q):
    px = input().split(' ')
    p = int(px[0])
    x = int(px[1])
    tree_dict[p]['count'] += x
    for num in tree_dict[p]['has_trees']:
        tree_dict[num]['count'] += x

out_put_list = []
for each_dict in tree_dict.values():
    out_put_list.append(str(each_dict['count']))
print(' '.join(out_put_list))

### FIXED CODE ###


NQ = input().split(' ')
N = int(NQ[0])
Q = int(NQ[1])
out_put_list = [0] * N
tree_list = {}
for i in range(N):
    tree_list[i] = []

for i in range(N-1):
    ab = input().split(' ')
    a = int(ab[0]) -1
    b = int(ab[1]) -1
    tree_list[a].append(b)

for _ in range(Q):
    px = input().split(' ')
    p = int(px[0])
    x = int(px[1])
    out_put_list[p-1] += x

for i in range(len(tree_list)):
    for num in tree_list[i]:
        out_put_list[num] += out_put_list[i]

print(*out_put_list)
### BUGGY CODE ###

from collections import defaultdict
from collections import deque
import sys
sys.setrecursionlimit(700000)

def setD(d, N):
    for i in range(N):
        d[i] = setsub(d, i)
            
def setsub(d, i):
    tmp = deque()
    for x in d[i]:
        tmp.append(x)
        if d[x] != 0:
            tmp += setsub(d, x)
    return tmp

N, Q = map(int, input().split())
d = defaultdict(deque)

for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    d[a].append(b)

setD(d, N)

ans = [0 for i in range(N)]

for i in range(Q):
    p, x = map(int, input().split())
    p -= 1
    ans[p] += x
    for i in d[p]:
        ans[i] += x


for i in range(N):
    ans[i] = str(ans[i])
print(" ".join(ans))

### FIXED CODE ###

N, Q = map(int, input().split())
d = [0 for i in range(N)]

for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    d[b] = a
ans = [0 for i in range(N)]

for i in range(Q):
    p, x = map(int, input().split())
    p -= 1
    ans[p] += x

for i in range(1, N):
    ans[i] += ans[d[i]]

print(*ans)