from sys import setrecursionlimit

setrecursionlimit(100000)

from collections import deque



S = input().split(" ")

N = int(S[0])

Q = int(S[1])



arr = []

prr = []

for i in range(N-1):

    S = input().split(" ")

    ar = [int(S[0]),int(S[1])]

    arr.append(ar)



for i in range(Q):

    S = input().split(" ")

    pr = [int(S[0]), int(S[1])]

    prr.append(pr)







def prepare(n, q, arr, prr):

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

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

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

    for ar in arr:

        start = ar[0] - 1

        end = ar[1] - 1

        links[start].append(end)

        links[end].append(start)



    for pr in prr:

        i = pr[0] - 1

        x = pr[1]

        values[i] += x



    return links, values, finalValues





links, values, finalValues = prepare(N, Q, arr, prr)





def bfs():

    q = deque()



    q.append((0,-1,0))



    while len(q) > 0:

        currentNode,parentNode,parentAccumulate = q.popleft()

        parentAccumulate += values[currentNode]

        finalValues[currentNode] += parentAccumulate

        childNodes = links[currentNode]

        for ch in childNodes:

            if ch == parentNode:

                continue

            q.append((ch,currentNode,finalValues[currentNode]))



bfs()

print((*finalValues))
import sys

sys.setrecursionlimit(10000000)

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



ARR = []



for i in range(N-1):

    ARR.append(list(map(int, input().split())))



BRR = []



for i in range(Q):

    BRR.append(list(map(int, input().split())))





def prepare(n, q, arr, brr):

    nodePoints = [0 for i in range(n)]

    for i in range(q):

        nodeIndex = brr[i][0] - 1

        nodePoints[nodeIndex] += brr[i][1]



    nodes = [[] for i in range(n)]



    for i in range(n - 1):

        startNode = arr[i][0] - 1

        endNode = arr[i][1] - 1



        nodes[startNode].append(endNode)

        nodes[endNode].append(startNode)



    return nodes, nodePoints





nodes, nodePoints = prepare(N, Q, ARR, BRR)





def dfs(currentNode, nodes, parentNode=-1, parentPoint=0):

    nodePoints[currentNode] = nodePoints[currentNode] + parentPoint

    childNodes = nodes[currentNode]

    for childNode in childNodes:

        if childNode == parentNode:

            continue

        dfs(childNode, nodes, currentNode, nodePoints[currentNode])





dfs(0, nodes)



print((" ".join([str(nodePoints[i]) for i in range(N)])))

from sys import setrecursionlimit

setrecursionlimit(100000)
from collections import deque

S = input().split(" ")
N = int(S[0])
Q = int(S[1])
arr = []
prr = []
for i in range(N - 1):
    S = input().split(" ")
    ar = [int(S[0]), int(S[1])]
    arr.append(ar)
for i in range(Q):
    S = input().split(" ")
    pr = [int(S[0]), int(S[1])]
    prr.append(pr)


def prepare(n, q, arr, prr):
    links = [[] for _ in range(n)]
    values = [0 for _ in range(n)]
    finalValues = [0 for _ in range(n)]
    for ar in arr:
        start = ar[0] - 1
        end = ar[1] - 1
        links[start].append(end)
        links[end].append(start)
    for pr in prr:
        i = pr[0] - 1
        x = pr[1]
        values[i] += x
    return links, values, finalValues


links, values, finalValues = prepare(N, Q, arr, prr)


def bfs():
    q = deque()
    q.append((0, -1, 0))
    while len(q) > 0:
        currentNode, parentNode, parentAccumulate = q.popleft()
        parentAccumulate += values[currentNode]
        finalValues[currentNode] += parentAccumulate
        childNodes = links[currentNode]
        for ch in childNodes:
            if ch == parentNode:
                continue
            q.append((ch, currentNode, finalValues[currentNode]))


bfs()
print((*finalValues))

import sys

sys.setrecursionlimit(10000000)
N, Q = list(map(int, input().split()))
ARR = []
for i in range(N - 1):
    ARR.append(list(map(int, input().split())))
BRR = []
for i in range(Q):
    BRR.append(list(map(int, input().split())))


def prepare(n, q, arr, brr):
    nodePoints = [0 for i in range(n)]
    for i in range(q):
        nodeIndex = brr[i][0] - 1
        nodePoints[nodeIndex] += brr[i][1]
    nodes = [[] for i in range(n)]
    for i in range(n - 1):
        startNode = arr[i][0] - 1
        endNode = arr[i][1] - 1
        nodes[startNode].append(endNode)
        nodes[endNode].append(startNode)
    return nodes, nodePoints


nodes, nodePoints = prepare(N, Q, ARR, BRR)


def dfs(currentNode, nodes, parentNode=-1, parentPoint=0):
    nodePoints[currentNode] = nodePoints[currentNode] + parentPoint
    childNodes = nodes[currentNode]
    for childNode in childNodes:
        if childNode == parentNode:
            continue
        dfs(childNode, nodes, currentNode, nodePoints[currentNode])


dfs(0, nodes)
print((" ".join([str(nodePoints[i]) for i in range(N)])))

-from sys import setrecursionlimit +import sys -setrecursionlimit(100000) -from collections import deque - -S = input().split(" ") -N = int(S[0]) -Q = int(S[1]) -arr = [] -prr = [] +sys.setrecursionlimit(10000000) +N, Q = list(map(int, input().split())) +ARR = [] -    S = input().split(" ") -    ar = [int(S[0]), int(S[1])] -    arr.append(ar) +    ARR.append(list(map(int, input().split()))) +BRR = [] -    S = input().split(" ") -    pr = [int(S[0]), int(S[1])] -    prr.append(pr) +    BRR.append(list(map(int, input().split()))) -def prepare(n, q, arr, prr): -    links = [[] for _ in range(n)] -    values = [0 for _ in range(n)] -    finalValues = [0 for _ in range(n)] -    for ar in arr: -        start = ar[0] - 1 -        end = ar[1] - 1 -        links[start].append(end) -        links[end].append(start) -    for pr in prr: -        i = pr[0] - 1 -        x = pr[1] -        values[i] += x -    return links, values, finalValues +def prepare(n, q, arr, brr): +    nodePoints = [0 for i in range(n)] +    for i in range(q): +        nodeIndex = brr[i][0] - 1 +        nodePoints[nodeIndex] += brr[i][1] +    nodes = [[] for i in range(n)] +    for i in range(n - 1): +        startNode = arr[i][0] - 1 +        endNode = arr[i][1] - 1 +        nodes[startNode].append(endNode) +        nodes[endNode].append(startNode) +    return nodes, nodePoints -links, values, finalValues = prepare(N, Q, arr, prr) +nodes, nodePoints = prepare(N, Q, ARR, BRR) -def bfs(): -    q = deque() -    q.append((0, -1, 0)) -    while len(q) > 0: -        currentNode, parentNode, parentAccumulate = q.popleft() -        parentAccumulate += values[currentNode] -        finalValues[currentNode] += parentAccumulate -        childNodes = links[currentNode] -        for ch in childNodes: -            if ch == parentNode: -                continue -            q.append((ch, currentNode, finalValues[currentNode])) +def dfs(currentNode, nodes, parentNode=-1, parentPoint=0): +    nodePoints[currentNode] = nodePoints[currentNode] + parentPoint +    childNodes = nodes[currentNode] +    for childNode in childNodes: +        if childNode == parentNode: +            continue +        dfs(childNode, nodes, currentNode, nodePoints[currentNode]) -bfs() -print((*finalValues)) +dfs(0, nodes) +print((" ".join([str(nodePoints[i]) for i in range(N)])))