from collections import deque



n, q = [int(i) for i in input().split()]



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

for _ in range(n-1):

    a, b = [int(i) for i in input().split()]

    tree[a].append(b)

    tree[b].append(a)



counter = [0] * (n+1)

for _ in range(q):

    p, x = [int(i) for i in input().split()]

    counter[p] += x



queue = deque([[0,1]])

while queue:

    parent, node = queue.popleft()

    for leaf in tree[node]:

        if leaf == parent:

            continue

        counter[leaf] += counter[node]

        queue.append([node, leaf])



print((*counter[1:]))

# ABC138D - Ki

from collections import deque

 

 

def dfs() -> None:

    # pop, appendまたはQueueライブラリだと間に合わない

    queue = deque([[0,1]])

    while queue:

        parent, node = queue.popleft()

        for leaf in T[node]:

            if leaf == parent:

                continue

            counter[leaf] += counter[node]

            queue.append([node, leaf])

 

 

def main():

    # Ai (A[i][0]) may be not a parent of Bi (A[i][1])

    global T, counter

    N, Q, *A = list(map(int, open(0).read().split()))

    E, P = A[: (N - 1) * 2], A[(N - 1) * 2 :]

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

    for v, u in zip(*[iter(E)] * 2):

        T[v].append(u), T[u].append(v)

    counter = [0] * (N + 1)

    for p, x in zip(*[iter(P)] * 2):

        counter[p] += x  # increase vertex p by x

    dfs()

    print((*counter[1:]))

 

 

if __name__ == "__main__":

    main()

from collections import deque

n, q = [int(i) for i in input().split()]
tree = [[] for _ in range(n + 1)]
for _ in range(n - 1):
    a, b = [int(i) for i in input().split()]
    tree[a].append(b)
    tree[b].append(a)
counter = [0] * (n + 1)
for _ in range(q):
    p, x = [int(i) for i in input().split()]
    counter[p] += x
queue = deque([[0, 1]])
while queue:
    parent, node = queue.popleft()
    for leaf in tree[node]:
        if leaf == parent:
            continue
        counter[leaf] += counter[node]
        queue.append([node, leaf])
print((*counter[1:]))

# ABC138D - Ki
from collections import deque


def dfs() -> None:
    # pop, appendまたはQueueライブラリだと間に合わない
    queue = deque([[0, 1]])
    while queue:
        parent, node = queue.popleft()
        for leaf in T[node]:
            if leaf == parent:
                continue
            counter[leaf] += counter[node]
            queue.append([node, leaf])


def main():
    # Ai (A[i][0]) may be not a parent of Bi (A[i][1])
    global T, counter
    N, Q, *A = list(map(int, open(0).read().split()))
    E, P = A[: (N - 1) * 2], A[(N - 1) * 2 :]
    T = [[] for _ in range(N + 1)]
    for v, u in zip(*[iter(E)] * 2):
        T[v].append(u), T[u].append(v)
    counter = [0] * (N + 1)
    for p, x in zip(*[iter(P)] * 2):
        counter[p] += x  # increase vertex p by x
    dfs()
    print((*counter[1:]))


if __name__ == "__main__":
    main()

+# ABC138D - Ki -n, q = [int(i) for i in input().split()] -tree = [[] for _ in range(n + 1)] -for _ in range(n - 1): -    a, b = [int(i) for i in input().split()] -    tree[a].append(b) -    tree[b].append(a) -counter = [0] * (n + 1) -for _ in range(q): -    p, x = [int(i) for i in input().split()] -    counter[p] += x -queue = deque([[0, 1]]) -while queue: -    parent, node = queue.popleft() -    for leaf in tree[node]: -        if leaf == parent: -            continue -        counter[leaf] += counter[node] -        queue.append([node, leaf]) -print((*counter[1:])) + +def dfs() -> None: +    # pop, appendまたはQueueライブラリだと間に合わない +    queue = deque([[0, 1]]) +    while queue: +        parent, node = queue.popleft() +        for leaf in T[node]: +            if leaf == parent: +                continue +            counter[leaf] += counter[node] +            queue.append([node, leaf]) + + +def main(): +    # Ai (A[i][0]) may be not a parent of Bi (A[i][1]) +    global T, counter +    N, Q, *A = list(map(int, open(0).read().split())) +    E, P = A[: (N - 1) * 2], A[(N - 1) * 2 :] +    T = [[] for _ in range(N + 1)] +    for v, u in zip(*[iter(E)] * 2): +        T[v].append(u), T[u].append(v) +    counter = [0] * (N + 1) +    for p, x in zip(*[iter(P)] * 2): +        counter[p] += x  # increase vertex p by x +    dfs() +    print((*counter[1:])) + + +if __name__ == "__main__": +    main()