I=lambda:list(map(int,input().split()));

n,q=I();r=[0]*n;e=[[]for _ in range(n)];y=[0]+[1]*n;s=[0]

for _ in range(n-1):a,b=I();e[a-1]+=b-1,;e[b-1]+=a-1,;

for _ in range(q):p,x=I();r[p-1]+=x;

while s:

  u=s.pop();v=r[u];

  for c in e[u]:

    if y[c]:y[c]=0;r[c]+=v;s+=c,;

print((*r))
n,q=list(map(int,input().split()))

from collections import deque

edge=[[] for _ in range(n)]

ans=[0]*n

for i in range(n-1):

  a,b=[int(x)-1 for x in input().split()]

  edge[a].append(b)

  edge[b].append(a)



for i in range(q):

  p,x=list(map(int,input().split()))

  p-=1

  ans[p]+=x



done=[False]*n

q=deque([])

q.append(0)

done[0]=True

while q:

  v=q.popleft()

  done[v]=True

  for c in edge[v]:

    if done[c]==False:

      ans[c]+=ans[v]

      q.append(c)

    

print((*ans)) 

  

I = lambda: list(map(int, input().split()))
n, q = I()
r = [0] * n
e = [[] for _ in range(n)]
y = [0] + [1] * n
s = [0]
for _ in range(n - 1):
    a, b = I()
    e[a - 1] += (b - 1,)
    e[b - 1] += (a - 1,)
for _ in range(q):
    p, x = I()
    r[p - 1] += x
while s:
    u = s.pop()
    v = r[u]
    for c in e[u]:
        if y[c]:
            y[c] = 0
            r[c] += v
            s += (c,)
print((*r))

n, q = list(map(int, input().split()))
from collections import deque

edge = [[] for _ in range(n)]
ans = [0] * n
for i in range(n - 1):
    a, b = [int(x) - 1 for x in input().split()]
    edge[a].append(b)
    edge[b].append(a)
for i in range(q):
    p, x = list(map(int, input().split()))
    p -= 1
    ans[p] += x
done = [False] * n
q = deque([])
q.append(0)
done[0] = True
while q:
    v = q.popleft()
    done[v] = True
    for c in edge[v]:
        if done[c] == False:
            ans[c] += ans[v]
            q.append(c)
print((*ans))

-I = lambda: list(map(int, input().split())) -n, q = I() -r = [0] * n -e = [[] for _ in range(n)] -y = [0] + [1] * n -s = [0] -for _ in range(n - 1): -    a, b = I() -    e[a - 1] += (b - 1,) -    e[b - 1] += (a - 1,) -for _ in range(q): -    p, x = I() -    r[p - 1] += x -while s: -    u = s.pop() -    v = r[u] -    for c in e[u]: -        if y[c]: -            y[c] = 0 -            r[c] += v -            s += (c,) -print((*r)) +n, q = list(map(int, input().split())) +from collections import deque + +edge = [[] for _ in range(n)] +ans = [0] * n +for i in range(n - 1): +    a, b = [int(x) - 1 for x in input().split()] +    edge[a].append(b) +    edge[b].append(a) +for i in range(q): +    p, x = list(map(int, input().split())) +    p -= 1 +    ans[p] += x +done = [False] * n +q = deque([]) +q.append(0) +done[0] = True +while q: +    v = q.popleft() +    done[v] = True +    for c in edge[v]: +        if done[c] == False: +            ans[c] += ans[v] +            q.append(c) +print((*ans))