import sys

sys.setrecursionlimit(1000000)

L = sys.stdin.readlines()

for i in range(len(L)):

    L[i] = list(map(int, L[i].split()))

n =L[0][0]



rin = [[] for _ in range(n)]

for v in L[1:n]:

    rin[v[0]-1].append(v[1]-1)

    rin[v[1]-1].append(v[0]-1)

    

score = [0 for _ in range(n)]

for ele in L[n:]:

    score[ele[0]-1] +=ele[1]

#print(score)

 

def dfs(p, bp=-1):

    for c in rin[p]:

        if c != bp:

            #print(c)

            score[c]+= score[p]

            dfs(c, p)

 

dfs(0)

print((*score))
#ABC138D

#node:節 edge:枝

def main():

    import sys

    sys.setrecursionlimit(200005)

    N, Q = list(map(int, sys.stdin.readline().split()))

    edge = [tuple(map(int, sys.stdin.readline().split())) for _ in range(N-1)]

    #1:ノードのリストを作る

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

    for a, b in edge:

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

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

    #print(nodeL)

    px = [tuple(map(int, sys.stdin.readline().split())) for _ in range(Q)]

    #print(px)

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

    for p, x in px:

        score[p-1] +=x

    #print(score)

    result = score.copy()

    

    def dfs(p, g=-1):

        for c in nodeL[p]:

            if c !=g:

                score[c] +=score[p]

                dfs(c, p)

    

    

    dfs(0)

    print((*score))

    





if __name__=='__main__':

    main()

import sys

sys.setrecursionlimit(1000000)
L = sys.stdin.readlines()
for i in range(len(L)):
    L[i] = list(map(int, L[i].split()))
n = L[0][0]
rin = [[] for _ in range(n)]
for v in L[1:n]:
    rin[v[0] - 1].append(v[1] - 1)
    rin[v[1] - 1].append(v[0] - 1)
score = [0 for _ in range(n)]
for ele in L[n:]:
    score[ele[0] - 1] += ele[1]
# print(score)
def dfs(p, bp=-1):
    for c in rin[p]:
        if c != bp:
            # print(c)
            score[c] += score[p]
            dfs(c, p)


dfs(0)
print((*score))

# ABC138D
# node:節 edge:枝
def main():
    import sys

    sys.setrecursionlimit(200005)
    N, Q = list(map(int, sys.stdin.readline().split()))
    edge = [tuple(map(int, sys.stdin.readline().split())) for _ in range(N - 1)]
    # 1:ノードのリストを作る
    nodeL = [[] for _ in range(N)]
    for a, b in edge:
        nodeL[a - 1].append(b - 1)
        nodeL[b - 1].append(a - 1)
    # print(nodeL)
    px = [tuple(map(int, sys.stdin.readline().split())) for _ in range(Q)]
    # print(px)
    score = [0 for i in range(N)]
    for p, x in px:
        score[p - 1] += x
    # print(score)
    result = score.copy()

    def dfs(p, g=-1):
        for c in nodeL[p]:
            if c != g:
                score[c] += score[p]
                dfs(c, p)

    dfs(0)
    print((*score))


if __name__ == "__main__":
    main()

-import sys +# ABC138D +# node:節 edge:枝 +def main(): +    import sys -sys.setrecursionlimit(1000000) -L = sys.stdin.readlines() -for i in range(len(L)): -    L[i] = list(map(int, L[i].split())) -n = L[0][0] -rin = [[] for _ in range(n)] -for v in L[1:n]: -    rin[v[0] - 1].append(v[1] - 1) -    rin[v[1] - 1].append(v[0] - 1) -score = [0 for _ in range(n)] -for ele in L[n:]: -    score[ele[0] - 1] += ele[1] -# print(score) -def dfs(p, bp=-1): -    for c in rin[p]: -        if c != bp: -            # print(c) -            score[c] += score[p] -            dfs(c, p) +    sys.setrecursionlimit(200005) +    N, Q = list(map(int, sys.stdin.readline().split())) +    edge = [tuple(map(int, sys.stdin.readline().split())) for _ in range(N - 1)] +    # 1:ノードのリストを作る +    nodeL = [[] for _ in range(N)] +    for a, b in edge: +        nodeL[a - 1].append(b - 1) +        nodeL[b - 1].append(a - 1) +    # print(nodeL) +    px = [tuple(map(int, sys.stdin.readline().split())) for _ in range(Q)] +    # print(px) +    score = [0 for i in range(N)] +    for p, x in px: +        score[p - 1] += x +    # print(score) +    result = score.copy() + +    def dfs(p, g=-1): +        for c in nodeL[p]: +            if c != g: +                score[c] += score[p] +                dfs(c, p) + +    dfs(0) +    print((*score)) -dfs(0) -print((*score)) +if __name__ == "__main__": +    main()