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

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

for i in range(n-1):

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

    a, b = a-1, b-1

    g[a].append(b)

    g[b].append(a)



X = [0]*n

for i in range(q):

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

    p -= 1

    X[p] += x



s = []

visit = [-1]*n

s.append(0)

visit[0] = 0

while s:

    v = s.pop()

    for u in g[v]:

        if visit[u] == -1:

            X[u] += X[v]

            s.append(u)

            visit[u] = 0

print((*X))

import sys

input = sys.stdin.buffer.readline



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

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

for i in range(n-1):

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

    a, b = a-1, b-1

    g[a].append(b)

    g[b].append(a)



X = [0]*n

for i in range(q):

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

    p = p-1

    X[p] += x



s = []

visited = [-1]*n

s.append(0)

visited[0] = 0

while s:

    v = s.pop()

    for u in g[v]:

        if visited[u] == -1:

            X[u] += X[v]

            visited[u] = 0

            s.append(u)

print((*X))

n, q = list(map(int, input().split()))
g = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    a, b = a - 1, b - 1
    g[a].append(b)
    g[b].append(a)
X = [0] * n
for i in range(q):
    p, x = list(map(int, input().split()))
    p -= 1
    X[p] += x
s = []
visit = [-1] * n
s.append(0)
visit[0] = 0
while s:
    v = s.pop()
    for u in g[v]:
        if visit[u] == -1:
            X[u] += X[v]
            s.append(u)
            visit[u] = 0
print((*X))

import sys

input = sys.stdin.buffer.readline
n, q = list(map(int, input().split()))
g = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    a, b = a - 1, b - 1
    g[a].append(b)
    g[b].append(a)
X = [0] * n
for i in range(q):
    p, x = list(map(int, input().split()))
    p = p - 1
    X[p] += x
s = []
visited = [-1] * n
s.append(0)
visited[0] = 0
while s:
    v = s.pop()
    for u in g[v]:
        if visited[u] == -1:
            X[u] += X[v]
            visited[u] = 0
            s.append(u)
print((*X))

+import sys + +input = sys.stdin.buffer.readline -    p -= 1 +    p = p - 1 -visit = [-1] * n +visited = [-1] * n -visit[0] = 0 +visited[0] = 0 -        if visit[u] == -1: +        if visited[u] == -1: +            visited[u] = 0 -            visit[u] = 0