import sys



input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)





def dfs(G, v, p, point):

    """G: graph, v: vertex, p: parent"""

    # Loop for each child

    for c in G[v]:

        if c == p:

            continue

        point[c] += point[v]

        dfs(G, c, v, point)





def main():

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

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

    for _ in range(N - 1):

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

        a -= 1

        b -= 1

        G[a].append(b)

        G[b].append(a)



    point = [0] * N

    for i in range(Q):

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

        p -= 1

        point[p] += x



    dfs(G, 0, -1, point)

    print((" ".join(map(str, point))))





if __name__ == "__main__":

    main()

import sys

input = sys.stdin.readline  # NOQA

sys.setrecursionlimit(10 ** 7)  # NOQA



from collections import deque





def dfs(G, v, p, counter):

    """G: graph, v: vertex, p: parent"""

    parent = [-1] * len(G)

    stack = deque([v])

    while stack:

        v = stack.pop()

        for c in G[v]:

            if c == parent[v]:

                continue

            parent[c] = v

            stack.append(c)

            counter[c] += counter[v]





def main():

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

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

    for _ in range(N - 1):

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

        a -= 1

        b -= 1

        G[a].append(b)

        G[b].append(a)



    counter = [0] * N

    for _ in range(Q):

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

        p -= 1

        counter[p] += x



    dfs(G, 0, -1, counter)

    print((*counter))





if __name__ == "__main__":

    main()

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)


def dfs(G, v, p, point):
    """G: graph, v: vertex, p: parent"""
    # Loop for each child
    for c in G[v]:
        if c == p:
            continue
        point[c] += point[v]
        dfs(G, c, v, point)


def main():
    N, Q = list(map(int, input().split()))
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = list(map(int, input().split()))
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)
    point = [0] * N
    for i in range(Q):
        p, x = list(map(int, input().split()))
        p -= 1
        point[p] += x
    dfs(G, 0, -1, point)
    print((" ".join(map(str, point))))


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline  # NOQA
sys.setrecursionlimit(10**7)  # NOQA
from collections import deque


def dfs(G, v, p, counter):
    """G: graph, v: vertex, p: parent"""
    parent = [-1] * len(G)
    stack = deque([v])
    while stack:
        v = stack.pop()
        for c in G[v]:
            if c == parent[v]:
                continue
            parent[c] = v
            stack.append(c)
            counter[c] += counter[v]


def main():
    N, Q = list(map(int, input().split()))
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = list(map(int, input().split()))
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)
    counter = [0] * N
    for _ in range(Q):
        p, x = list(map(int, input().split()))
        p -= 1
        counter[p] += x
    dfs(G, 0, -1, counter)
    print((*counter))


if __name__ == "__main__":
    main()

-input = sys.stdin.readline -sys.setrecursionlimit(10**7) +input = sys.stdin.readline  # NOQA +sys.setrecursionlimit(10**7)  # NOQA +from collections import deque -def dfs(G, v, p, point): +def dfs(G, v, p, counter): -    # Loop for each child -    for c in G[v]: -        if c == p: -            continue -        point[c] += point[v] -        dfs(G, c, v, point) +    parent = [-1] * len(G) +    stack = deque([v]) +    while stack: +        v = stack.pop() +        for c in G[v]: +            if c == parent[v]: +                continue +            parent[c] = v +            stack.append(c) +            counter[c] += counter[v] -    point = [0] * N -    for i in range(Q): +    counter = [0] * N +    for _ in range(Q): -        point[p] += x -    dfs(G, 0, -1, point) -    print((" ".join(map(str, point)))) +        counter[p] += x +    dfs(G, 0, -1, counter) +    print((*counter))