import sys

from collections import deque

sys.setrecursionlimit(500000)

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

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

cost=[0]*n

for i in range(n-1):

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

  p-=1;s-=1

  edge[p].append(s)

  edge[s].append(p)

for i in range(q):

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

  x-=1

  cost[x]+=c

visited=[False]*n

queue=deque([0])

visited[0]=True

while len(queue)!=0:

  a=queue.popleft()

  for i in edge[a]:

    if visited[i]==True:continue

    queue.append(i)

    visited[i]=True

    cost[i]+=cost[a]

for i in range(n):

  cost[i]=str(cost[i])

print((" ".join(cost)))
import sys

from collections import deque

sys.setrecursionlimit(500000)

input=sys.stdin.readline

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

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

cost=[0]*n

for i in range(n-1):

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

  p-=1;s-=1

  edge[p].append(s)

  edge[s].append(p)

for i in range(q):

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

  x-=1

  cost[x]+=c

visited=[False]*n

queue=deque([0])

visited[0]=True

while len(queue)!=0:

  a=queue.popleft()

  for i in edge[a]:

    if visited[i]==True:continue

    queue.append(i)

    visited[i]=True

    cost[i]+=cost[a]

for i in range(n):

  cost[i]=str(cost[i])

print((" ".join(cost)))

import sys
from collections import deque

sys.setrecursionlimit(500000)
n, q = list(map(int, input().split()))
edge = [[] for i in range(n)]
cost = [0] * n
for i in range(n - 1):
    p, s = list(map(int, input().split()))
    p -= 1
    s -= 1
    edge[p].append(s)
    edge[s].append(p)
for i in range(q):
    x, c = list(map(int, input().split()))
    x -= 1
    cost[x] += c
visited = [False] * n
queue = deque([0])
visited[0] = True
while len(queue) != 0:
    a = queue.popleft()
    for i in edge[a]:
        if visited[i] == True:
            continue
        queue.append(i)
        visited[i] = True
        cost[i] += cost[a]
for i in range(n):
    cost[i] = str(cost[i])
print((" ".join(cost)))

import sys
from collections import deque

sys.setrecursionlimit(500000)
input = sys.stdin.readline
n, q = list(map(int, input().split()))
edge = [[] for i in range(n)]
cost = [0] * n
for i in range(n - 1):
    p, s = list(map(int, input().split()))
    p -= 1
    s -= 1
    edge[p].append(s)
    edge[s].append(p)
for i in range(q):
    x, c = list(map(int, input().split()))
    x -= 1
    cost[x] += c
visited = [False] * n
queue = deque([0])
visited[0] = True
while len(queue) != 0:
    a = queue.popleft()
    for i in edge[a]:
        if visited[i] == True:
            continue
        queue.append(i)
        visited[i] = True
        cost[i] += cost[a]
for i in range(n):
    cost[i] = str(cost[i])
print((" ".join(cost)))

+input = sys.stdin.readline