import sys

input = sys.stdin.readline

sys.setrecursionlimit(10**7)



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

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

for _ in range(n-1):

    a, b = list([int(x)-1 for x in input().split()])

    edges[a].append(b)

    edges[b].append(a)



nodes = [0]*n

for _ in range(q):

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

    nodes[p-1] += x



def dfs(v, parent, add):

    nodes[v] += add

    for v2 in edges[v]:

        if v2 == parent:

            continue

        dfs(v2, v, nodes[v])



dfs(0, -1, 0)

print((*nodes))
import sys

input = sys.stdin.readline

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

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

for _ in range(n-1):

    a, b = list([int(x)-1 for x in input().split()])

    edges[a].append(b)

    edges[b].append(a)



values = [0]*n

for _ in range(q):

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

    values[p-1] += x



stack = [0]

visited = [0]*n

while stack:

    v = stack.pop()

    if visited[v]:

        continue

    visited[v] = 1

    for v2 in edges[v]:

        if visited[v2]:

            continue

        values[v2] += values[v]

        stack.append(v2)

print((*values))

import sys

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


def dfs(v, parent, add):
    nodes[v] += add
    for v2 in edges[v]:
        if v2 == parent:
            continue
        dfs(v2, v, nodes[v])


dfs(0, -1, 0)
print((*nodes))

import sys

input = sys.stdin.readline
n, q = list(map(int, input().split()))
edges = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = list([int(x) - 1 for x in input().split()])
    edges[a].append(b)
    edges[b].append(a)
values = [0] * n
for _ in range(q):
    p, x = list(map(int, input().split()))
    values[p - 1] += x
stack = [0]
visited = [0] * n
while stack:
    v = stack.pop()
    if visited[v]:
        continue
    visited[v] = 1
    for v2 in edges[v]:
        if visited[v2]:
            continue
        values[v2] += values[v]
        stack.append(v2)
print((*values))

-sys.setrecursionlimit(10**7) -nodes = [0] * n +values = [0] * n -    nodes[p - 1] += x - - -def dfs(v, parent, add): -    nodes[v] += add +    values[p - 1] += x +stack = [0] +visited = [0] * n +while stack: +    v = stack.pop() +    if visited[v]: +        continue +    visited[v] = 1 -        if v2 == parent: +        if visited[v2]: -        dfs(v2, v, nodes[v]) - - -dfs(0, -1, 0) -print((*nodes)) +        values[v2] += values[v] +        stack.append(v2) +print((*values))