from collections import deque

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

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

cnt=[0 for i in range(n)]

visited=[-1 for i in range(n)]

for i in range(n-1):

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

  a-=1

  b-=1

  edge[a].append(b)

  edge[b].append(a)

for i in range(q):

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

  cnt[p-1]+=x

def dfs(edge,cnt,visited):

  stack=deque([0])

  visited[0]=0

  while stack:

    x=stack.pop()

    for i in edge[x]:

      newx=i

      if visited[newx]==-1:

        visited[newx]=0

        cnt[newx]+=cnt[x]

        stack.append(newx)

  return cnt

print((*dfs(edge,cnt,visited)))

from collections import deque

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

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

for _ in range(n-1):

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

  a-=1

  b-=1

  edge[a].append(b)

  edge[b].append(a)

def dfs(edge):

  visited=[-1]*n

  stack=deque([0])

  visited[0]=0

  while stack:

    p=stack.pop()

    for c in edge[p]:

      if visited[c]==-1:

        visited[c]=0

        cnt[c]+=cnt[p]

        stack.append(c)

  return cnt

cnt=[0]*n

for _ in range(q):

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

  k-=1

  cnt[k]+=x

ans=dfs(edge)

print((*ans))
from collections import deque

n, q = list(map(int, input().split()))
edge = [[] for i in range(n)]
cnt = [0 for i in range(n)]
visited = [-1 for i in range(n)]
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
for i in range(q):
    p, x = list(map(int, input().split()))
    cnt[p - 1] += x


def dfs(edge, cnt, visited):
    stack = deque([0])
    visited[0] = 0
    while stack:
        x = stack.pop()
        for i in edge[x]:
            newx = i
            if visited[newx] == -1:
                visited[newx] = 0
                cnt[newx] += cnt[x]
                stack.append(newx)
    return cnt


print((*dfs(edge, cnt, visited)))

from collections import deque

n, q = list(map(int, input().split()))
edge = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)


def dfs(edge):
    visited = [-1] * n
    stack = deque([0])
    visited[0] = 0
    while stack:
        p = stack.pop()
        for c in edge[p]:
            if visited[c] == -1:
                visited[c] = 0
                cnt[c] += cnt[p]
                stack.append(c)
    return cnt


cnt = [0] * n
for _ in range(q):
    k, x = list(map(int, input().split()))
    k -= 1
    cnt[k] += x
ans = dfs(edge)
print((*ans))

-edge = [[] for i in range(n)] -cnt = [0 for i in range(n)] -visited = [-1 for i in range(n)] -for i in range(n - 1): +edge = [[] for _ in range(n)] +for _ in range(n - 1): -for i in range(q): -    p, x = list(map(int, input().split())) -    cnt[p - 1] += x -def dfs(edge, cnt, visited): +def dfs(edge): +    visited = [-1] * n -        x = stack.pop() -        for i in edge[x]: -            newx = i -            if visited[newx] == -1: -                visited[newx] = 0 -                cnt[newx] += cnt[x] -                stack.append(newx) +        p = stack.pop() +        for c in edge[p]: +            if visited[c] == -1: +                visited[c] = 0 +                cnt[c] += cnt[p] +                stack.append(c) -print((*dfs(edge, cnt, visited))) +cnt = [0] * n +for _ in range(q): +    k, x = list(map(int, input().split())) +    k -= 1 +    cnt[k] += x +ans = dfs(edge) +print((*ans))