from collections import deque

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

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

for _ in range(n-1):

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

  g[a-1].append(b-1)

  g[b-1].append(a-1)



s=[0]*n

for _ in range(q):

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

  s[p-1]+=x



que=deque([0])

f=[0]*n

f[0]=1

while que:

  v=que.popleft()

  c=s[v]

  for w in g[v]:

    if f[w]:

      continue

    f[w]=1

    s[w]+=c

    que.append(w)

  

print((*s))
import sys

sys.setrecursionlimit(10**7)

 

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

root = [[] for i in range(N)]

ans = [0]*N

 

for i in range(N-1):

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

  a, b = a-1, b-1

  root[a].append(b)

  root[b].append(a)



for i in range(Q):

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

  ans[p-1] += x

  

visit = [False]*N

def dfs(n):

  visit[n] = True

  for go in root[n]:

    if visit[go]:

      continue

    ans[go] += ans[n]

    dfs(go)



dfs(0)

print((*ans))
from collections import deque

n, q = list(map(int, input().split()))
g = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = list(map(int, input().split()))
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)
s = [0] * n
for _ in range(q):
    p, x = list(map(int, input().split()))
    s[p - 1] += x
que = deque([0])
f = [0] * n
f[0] = 1
while que:
    v = que.popleft()
    c = s[v]
    for w in g[v]:
        if f[w]:
            continue
        f[w] = 1
        s[w] += c
        que.append(w)
print((*s))

import sys

sys.setrecursionlimit(10**7)
N, Q = list(map(int, input().split()))
root = [[] for i in range(N)]
ans = [0] * N
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    a, b = a - 1, b - 1
    root[a].append(b)
    root[b].append(a)
for i in range(Q):
    p, x = list(map(int, input().split()))
    ans[p - 1] += x
visit = [False] * N


def dfs(n):
    visit[n] = True
    for go in root[n]:
        if visit[go]:
            continue
        ans[go] += ans[n]
        dfs(go)


dfs(0)
print((*ans))

-from collections import deque +import sys -n, q = list(map(int, input().split())) -g = [[] for _ in range(n)] -for _ in range(n - 1): +sys.setrecursionlimit(10**7) +N, Q = list(map(int, input().split())) +root = [[] for i in range(N)] +ans = [0] * N +for i in range(N - 1): -    g[a - 1].append(b - 1) -    g[b - 1].append(a - 1) -s = [0] * n -for _ in range(q): +    a, b = a - 1, b - 1 +    root[a].append(b) +    root[b].append(a) +for i in range(Q): -    s[p - 1] += x -que = deque([0]) -f = [0] * n -f[0] = 1 -while que: -    v = que.popleft() -    c = s[v] -    for w in g[v]: -        if f[w]: +    ans[p - 1] += x +visit = [False] * N + + +def dfs(n): +    visit[n] = True +    for go in root[n]: +        if visit[go]: -        f[w] = 1 -        s[w] += c -        que.append(w) -print((*s)) +        ans[go] += ans[n] +        dfs(go) + + +dfs(0) +print((*ans))