import sys

sys.setrecursionlimit(10**6)



def MI(): return list(map(int, input().split()))



N,Q=MI()

Edge=[[] for _ in range(N)]

Point=[0]*N



for i in range(N-1):

  a,b=MI()

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

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



for i in range(Q):

  p,x=MI()

  Point[p-1]+=x



def dfs(now,pre=-1):

  for nxt in Edge[now]:

    if nxt==pre:

      continue

    Point[nxt]+=Point[now]

    dfs(nxt,now)

dfs(0)

print((*Point))
from collections import deque

def MI(): return list(map(int, input().split()))

N,Q=MI()

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

Point=[0]*N

for i in range(N-1):

  a,b=MI()

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

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

for i in range(Q):

  p,x=MI()

  Point[p-1]+=x

que=deque([])

que.append(0)

check=[0]*N

while que:

  v=que.pop()

  check[v]=1

  for u in graph[v]:

    if check[u]!=1:

      #continue

      Point[u]+=Point[v]

      que.append(u)

print((*Point))
import sys

sys.setrecursionlimit(10**6)


def MI():
    return list(map(int, input().split()))


N, Q = MI()
Edge = [[] for _ in range(N)]
Point = [0] * N
for i in range(N - 1):
    a, b = MI()
    Edge[a - 1].append(b - 1)
    Edge[b - 1].append(a - 1)
for i in range(Q):
    p, x = MI()
    Point[p - 1] += x


def dfs(now, pre=-1):
    for nxt in Edge[now]:
        if nxt == pre:
            continue
        Point[nxt] += Point[now]
        dfs(nxt, now)


dfs(0)
print((*Point))

from collections import deque


def MI():
    return list(map(int, input().split()))


N, Q = MI()
graph = [[] for i in range(N)]
Point = [0] * N
for i in range(N - 1):
    a, b = MI()
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
for i in range(Q):
    p, x = MI()
    Point[p - 1] += x
que = deque([])
que.append(0)
check = [0] * N
while que:
    v = que.pop()
    check[v] = 1
    for u in graph[v]:
        if check[u] != 1:
            # continue
            Point[u] += Point[v]
            que.append(u)
print((*Point))

-import sys - -sys.setrecursionlimit(10**6) +from collections import deque -Edge = [[] for _ in range(N)] +graph = [[] for i in range(N)] -    Edge[a - 1].append(b - 1) -    Edge[b - 1].append(a - 1) +    graph[a - 1].append(b - 1) +    graph[b - 1].append(a - 1) - - -def dfs(now, pre=-1): -    for nxt in Edge[now]: -        if nxt == pre: -            continue -        Point[nxt] += Point[now] -        dfs(nxt, now) - - -dfs(0) +que = deque([]) +que.append(0) +check = [0] * N +while que: +    v = que.pop() +    check[v] = 1 +    for u in graph[v]: +        if check[u] != 1: +            # continue +            Point[u] += Point[v] +            que.append(u)