import sys

sys.setrecursionlimit(10**7)

input = sys.stdin.readline

N, Q = list(map(int, input().split()))

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

point = [0]*N

for i in range(N-1):

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

    a -= 1

    b -= 1

    graph[a].append(b)

    graph[b].append(a)

for i in range(Q):

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

    point[p-1] += x

def dfs(s,parent):

    for i in graph[s]:

        if i == parent:

            continue

        point[i] += point[s]

        dfs(i,s)

dfs(0,-1)

print((*point))
import sys

sys.setrecursionlimit(10**7)

N, Q = list(map(int, input().split()))

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

for _ in range(N-1):

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

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

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

Query = [0]*N

for _ in range(Q):

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

    Query[p-1] += x

ans = [0]*N

past = [0]*N

def dfs(start,point):

    past[start] = 1

    point = point + Query[start]

    ans[start] = point

    for target in edges[start]:

        if past[target] == 0:

            dfs(target,point)

dfs(0,0)

print((*ans))
import sys

sys.setrecursionlimit(10**7)
input = sys.stdin.readline
N, Q = list(map(int, input().split()))
graph = [[] for _ in range(N)]
point = [0] * N
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
for i in range(Q):
    p, x = list(map(int, input().split()))
    point[p - 1] += x


def dfs(s, parent):
    for i in graph[s]:
        if i == parent:
            continue
        point[i] += point[s]
        dfs(i, s)


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

import sys

sys.setrecursionlimit(10**7)
N, Q = list(map(int, input().split()))
edges = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)
Query = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    Query[p - 1] += x
ans = [0] * N
past = [0] * N


def dfs(start, point):
    past[start] = 1
    point = point + Query[start]
    ans[start] = point
    for target in edges[start]:
        if past[target] == 0:
            dfs(target, point)


dfs(0, 0)
print((*ans))

-input = sys.stdin.readline -graph = [[] for _ in range(N)] -point = [0] * N -for i in range(N - 1): +edges = [[] for _ in range(N)] +for _ in range(N - 1): -    a -= 1 -    b -= 1 -    graph[a].append(b) -    graph[b].append(a) -for i in range(Q): +    edges[a - 1].append(b - 1) +    edges[b - 1].append(a - 1) +Query = [0] * N +for _ in range(Q): -    point[p - 1] += x +    Query[p - 1] += x +ans = [0] * N +past = [0] * N -def dfs(s, parent): -    for i in graph[s]: -        if i == parent: -            continue -        point[i] += point[s] -        dfs(i, s) +def dfs(start, point): +    past[start] = 1 +    point = point + Query[start] +    ans[start] = point +    for target in edges[start]: +        if past[target] == 0: +            dfs(target, point) -dfs(0, -1) -print((*point)) +dfs(0, 0) +print((*ans))