import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)

 



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



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



for i in range(N-1):

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

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

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



X = [0 for i in range(N)]

for i in range(Q):

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

    X[p-1] += x



def dfs(x, p):

    for j in T[x]:

        if j == p:

            continue

        X[j] += X[x]

        dfs(j, x)



dfs(0, -1)



for i in range(N):

    print(X[i], end =" ")

def main():

    import sys

    input = sys.stdin.readline

    sys.setrecursionlimit(10 ** 7)

    

    

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

    

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

    

    for i in range(N-1):

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

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

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

    

    X = [0 for i in range(N)]

    for i in range(Q):

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

        X[p-1] += x

    

    def dfs(x, p):

        for j in T[x]:

            if j == p:

                continue

            X[j] += X[x]

            dfs(j, x)

    

    dfs(0, -1)

    

    for i in range(N):

        print(X[i], end =" ")

main()

import sys

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


def dfs(x, p):
    for j in T[x]:
        if j == p:
            continue
        X[j] += X[x]
        dfs(j, x)


dfs(0, -1)
for i in range(N):
    print(X[i], end=" ")

def main():
    import sys

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

    def dfs(x, p):
        for j in T[x]:
            if j == p:
                continue
            X[j] += X[x]
            dfs(j, x)

    dfs(0, -1)
    for i in range(N):
        print(X[i], end=" ")


main()

-import sys +def main(): +    import sys -input = sys.stdin.readline -sys.setrecursionlimit(10**7) -N, Q = map(int, input().split()) -T = [[] for i in range(N)] -for i in range(N - 1): -    a, b = map(int, input().split()) -    T[a - 1].append(b - 1) -    T[b - 1].append(a - 1) -X = [0 for i in range(N)] -for i in range(Q): -    p, x = map(int, input().split()) -    X[p - 1] += x +    input = sys.stdin.readline +    sys.setrecursionlimit(10**7) +    N, Q = map(int, input().split()) +    T = [[] for i in range(N)] +    for i in range(N - 1): +        a, b = map(int, input().split()) +        T[a - 1].append(b - 1) +        T[b - 1].append(a - 1) +    X = [0 for i in range(N)] +    for i in range(Q): +        p, x = map(int, input().split()) +        X[p - 1] += x + +    def dfs(x, p): +        for j in T[x]: +            if j == p: +                continue +            X[j] += X[x] +            dfs(j, x) + +    dfs(0, -1) +    for i in range(N): +        print(X[i], end=" ") -def dfs(x, p): -    for j in T[x]: -        if j == p: -            continue -        X[j] += X[x] -        dfs(j, x) - - -dfs(0, -1) -for i in range(N): -    print(X[i], end=" ") +main()