from collections import deque



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

edge = [[] for i in range(N)]

ops = []

ans = [0] * N



for _ in range(N - 1):

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

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

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

for _ in range(Q):

    ops.append(tuple(map(int, input().split())))



for op in ops:

    node = op[0] - 1

    pnt = op[1]

    ans[node] += pnt



stack = deque()

stack.append((0, -1))



while stack:

    st = stack.pop()

    node, parent = st[0], st[1]

    children = edge[node]

    for child in children:

        if child == parent:

            continue

        ans[child] += ans[node]

        stack.append((child, node))



print((*ans))
from collections import deque





def main():

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

    edge = [[] for i in range(N)]

    ops = []

    ans = [0] * N

    

    for _ in range(N - 1):

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

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

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

    for _ in range(Q):

        ops.append(tuple(map(int, input().split())))

    

    for op in ops:

        node = op[0] - 1

        pnt = op[1]

        ans[node] += pnt

    

    stack = deque()

    stack.append((0, -1))

    

    while stack:

        st = stack.pop()

        node, parent = st[0], st[1]

        children = edge[node]

        for child in children:

            if child == parent:

                continue

            ans[child] += ans[node]

            stack.append((child, node))

    

    print((*ans))





if __name__ == '__main__':

    main()

from collections import deque

N, Q = list(map(int, input().split()))
edge = [[] for i in range(N)]
ops = []
ans = [0] * N
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)
for _ in range(Q):
    ops.append(tuple(map(int, input().split())))
for op in ops:
    node = op[0] - 1
    pnt = op[1]
    ans[node] += pnt
stack = deque()
stack.append((0, -1))
while stack:
    st = stack.pop()
    node, parent = st[0], st[1]
    children = edge[node]
    for child in children:
        if child == parent:
            continue
        ans[child] += ans[node]
        stack.append((child, node))
print((*ans))

from collections import deque


def main():
    N, Q = list(map(int, input().split()))
    edge = [[] for i in range(N)]
    ops = []
    ans = [0] * N
    for _ in range(N - 1):
        a, b = list(map(int, input().split()))
        edge[a - 1].append(b - 1)
        edge[b - 1].append(a - 1)
    for _ in range(Q):
        ops.append(tuple(map(int, input().split())))
    for op in ops:
        node = op[0] - 1
        pnt = op[1]
        ans[node] += pnt
    stack = deque()
    stack.append((0, -1))
    while stack:
        st = stack.pop()
        node, parent = st[0], st[1]
        children = edge[node]
        for child in children:
            if child == parent:
                continue
            ans[child] += ans[node]
            stack.append((child, node))
    print((*ans))


if __name__ == "__main__":
    main()

-N, Q = list(map(int, input().split())) -edge = [[] for i in range(N)] -ops = [] -ans = [0] * N -for _ in range(N - 1): -    a, b = list(map(int, input().split())) -    edge[a - 1].append(b - 1) -    edge[b - 1].append(a - 1) -for _ in range(Q): -    ops.append(tuple(map(int, input().split()))) -for op in ops: -    node = op[0] - 1 -    pnt = op[1] -    ans[node] += pnt -stack = deque() -stack.append((0, -1)) -while stack: -    st = stack.pop() -    node, parent = st[0], st[1] -    children = edge[node] -    for child in children: -        if child == parent: -            continue -        ans[child] += ans[node] -        stack.append((child, node)) -print((*ans)) + +def main(): +    N, Q = list(map(int, input().split())) +    edge = [[] for i in range(N)] +    ops = [] +    ans = [0] * N +    for _ in range(N - 1): +        a, b = list(map(int, input().split())) +        edge[a - 1].append(b - 1) +        edge[b - 1].append(a - 1) +    for _ in range(Q): +        ops.append(tuple(map(int, input().split()))) +    for op in ops: +        node = op[0] - 1 +        pnt = op[1] +        ans[node] += pnt +    stack = deque() +    stack.append((0, -1)) +    while stack: +        st = stack.pop() +        node, parent = st[0], st[1] +        children = edge[node] +        for child in children: +            if child == parent: +                continue +            ans[child] += ans[node] +            stack.append((child, node)) +    print((*ans)) + + +if __name__ == "__main__": +    main()