import sys

input=sys.stdin.readline

def main():

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

    X = [list(map(int,input().split())) for _ in range(N-1)]

    Y = [list(map(int,input().split())) for _ in range(Q)]



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

    for i in range(N-1):

        con[X[i][0]-1]+=[X[i][1]-1]

        con[X[i][1]-1]+=[X[i][0]-1]



    dif = [0]*N

    for i in range(Q):

        dif[Y[i][0]-1] += Y[i][1]



    root = [0]

    while root:

        cur = root.pop()

        for i in con[cur]:

            dif[i] += dif[cur]

            con[i].remove(cur)

            root.append(i) 

    print((*dif))



if __name__ == "__main__":

    main()
import sys

input=sys.stdin.readline

from collections import deque



def main():

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

    X = [list(map(int,input().split())) for _ in range(N-1)]

    Y = [list(map(int,input().split())) for _ in range(Q)]



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

    for i in range(N-1):

        con[X[i][0]-1]+=[X[i][1]-1]

        con[X[i][1]-1]+=[X[i][0]-1]



    dif = [0]*N

    for i in range(Q):

        dif[Y[i][0]-1] += Y[i][1]



    root = deque([0])

    go = [True for _ in range(N)]

    go[0] = False

    while root:

        cur = root.pop()

        for fol in con[cur]:

            if go[fol]:

                dif[fol] += dif[cur]

                go[fol] = False

                root.append(fol)



    print((*dif))



if __name__ == "__main__":

    main()

import sys

input = sys.stdin.readline


def main():
    N, Q = list(map(int, input().split()))
    X = [list(map(int, input().split())) for _ in range(N - 1)]
    Y = [list(map(int, input().split())) for _ in range(Q)]
    con = [[] for _ in range(N)]
    for i in range(N - 1):
        con[X[i][0] - 1] += [X[i][1] - 1]
        con[X[i][1] - 1] += [X[i][0] - 1]
    dif = [0] * N
    for i in range(Q):
        dif[Y[i][0] - 1] += Y[i][1]
    root = [0]
    while root:
        cur = root.pop()
        for i in con[cur]:
            dif[i] += dif[cur]
            con[i].remove(cur)
            root.append(i)
    print((*dif))


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline
from collections import deque


def main():
    N, Q = list(map(int, input().split()))
    X = [list(map(int, input().split())) for _ in range(N - 1)]
    Y = [list(map(int, input().split())) for _ in range(Q)]
    con = [[] for _ in range(N)]
    for i in range(N - 1):
        con[X[i][0] - 1] += [X[i][1] - 1]
        con[X[i][1] - 1] += [X[i][0] - 1]
    dif = [0] * N
    for i in range(Q):
        dif[Y[i][0] - 1] += Y[i][1]
    root = deque([0])
    go = [True for _ in range(N)]
    go[0] = False
    while root:
        cur = root.pop()
        for fol in con[cur]:
            if go[fol]:
                dif[fol] += dif[cur]
                go[fol] = False
                root.append(fol)
    print((*dif))


if __name__ == "__main__":
    main()

+from collections import deque -    root = [0] +    root = deque([0]) +    go = [True for _ in range(N)] +    go[0] = False -        for i in con[cur]: -            dif[i] += dif[cur] -            con[i].remove(cur) -            root.append(i) +        for fol in con[cur]: +            if go[fol]: +                dif[fol] += dif[cur] +                go[fol] = False +                root.append(fol)