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

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

for _ in range(n-1):

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

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

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

dist = [-1]*n

dist[0] = 1

A = [0]*n

F = [0]*n

for _ in range(q):

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

  F[p-1] += x

S = [0]

T = [0]

while S:

  v = S.pop()

  for nv in C[v]:

    if dist[nv] == -1:

      dist[nv] = dist[v] + 1

      S.append(nv)

while T:

  v = T.pop()

  A[v] += F[v]

  for nv in C[v]:

    if dist[nv] > dist[v]:

      A[nv] += A[v]

      T.append(nv)

print((*A))
import sys

input = sys.stdin.readline

sys.setrecursionlimit(10**7)



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

T = [[] for _ in range(n+1)]

for _ in range(n-1):

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

  T[a].append(b)

  T[b].append(a)

dp = [0]*(n+1)

for _ in range(q):

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

  dp[p] += x



seen = [False]*(n+1)

def dfs(v):

  seen[v] = True

  for nv in T[v]:

    if seen[nv]:

      continue

    dp[nv] += dp[v]

    dfs(nv)

dfs(1)

print((*dp[1:]))
n, q = list(map(int, input().split()))
C = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = list(map(int, input().split()))
    C[a - 1].append(b - 1)
    C[b - 1].append(a - 1)
dist = [-1] * n
dist[0] = 1
A = [0] * n
F = [0] * n
for _ in range(q):
    p, x = list(map(int, input().split()))
    F[p - 1] += x
S = [0]
T = [0]
while S:
    v = S.pop()
    for nv in C[v]:
        if dist[nv] == -1:
            dist[nv] = dist[v] + 1
            S.append(nv)
while T:
    v = T.pop()
    A[v] += F[v]
    for nv in C[v]:
        if dist[nv] > dist[v]:
            A[nv] += A[v]
            T.append(nv)
print((*A))

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n, q = list(map(int, input().split()))
T = [[] for _ in range(n + 1)]
for _ in range(n - 1):
    a, b = list(map(int, input().split()))
    T[a].append(b)
    T[b].append(a)
dp = [0] * (n + 1)
for _ in range(q):
    p, x = list(map(int, input().split()))
    dp[p] += x
seen = [False] * (n + 1)


def dfs(v):
    seen[v] = True
    for nv in T[v]:
        if seen[nv]:
            continue
        dp[nv] += dp[v]
        dfs(nv)


dfs(1)
print((*dp[1:]))

+import sys + +input = sys.stdin.readline +sys.setrecursionlimit(10**7) -C = [[] for _ in range(n)] +T = [[] for _ in range(n + 1)] -    C[a - 1].append(b - 1) -    C[b - 1].append(a - 1) -dist = [-1] * n -dist[0] = 1 -A = [0] * n -F = [0] * n +    T[a].append(b) +    T[b].append(a) +dp = [0] * (n + 1) -    F[p - 1] += x -S = [0] -T = [0] -while S: -    v = S.pop() -    for nv in C[v]: -        if dist[nv] == -1: -            dist[nv] = dist[v] + 1 -            S.append(nv) -while T: -    v = T.pop() -    A[v] += F[v] -    for nv in C[v]: -        if dist[nv] > dist[v]: -            A[nv] += A[v] -            T.append(nv) -print((*A)) +    dp[p] += x +seen = [False] * (n + 1) + + +def dfs(v): +    seen[v] = True +    for nv in T[v]: +        if seen[nv]: +            continue +        dp[nv] += dp[v] +        dfs(nv) + + +dfs(1) +print((*dp[1:]))