from collections import deque

n, q = list(map(int,input().split()))

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

for i in range(n-1):

    ai, bi = list(map(int,input().split()))

    d[ai-1].append(bi-1)

    d[bi-1].append(ai-1)

#point

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

for i in range(q):

    pi,xi = list(map(int,input().split()))

    px[pi-1] += xi

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

s = deque()

s.append(0)

visited = [False for i in range(n)]

while len(s) > 0:

    x = s.popleft()

    visited[x] = True

    sp[x] += px[x]

    for xc in d[x]:

        if not visited[xc]:

            s.append(xc)

            sp[xc] += sp[x]

for i in range(n):

    print((sp[i]))

import sys

from collections import deque

def input():

    return sys.stdin.readline()[:-1]

n, q = list(map(int,input().split()))

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

for i in range(n-1):

    ai, bi = list(map(int,input().split()))

    d[ai-1].append(bi-1)

    d[bi-1].append(ai-1)

#point

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

for i in range(q):

    pi,xi = list(map(int,input().split()))

    px[pi-1] += xi

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

s = deque()

s.append(0)

visited = [False for i in range(n)]

while len(s) > 0:

    x = s.popleft()

    visited[x] = True

    sp[x] += px[x]

    for xc in d[x]:

        if not visited[xc]:

            s.append(xc)

            sp[xc] += sp[x]

for i in range(n):

    print((sp[i]))

from collections import deque

n, q = list(map(int, input().split()))
d = [[] for i in range(n)]
for i in range(n - 1):
    ai, bi = list(map(int, input().split()))
    d[ai - 1].append(bi - 1)
    d[bi - 1].append(ai - 1)
# point
px = [0 for i in range(n)]
for i in range(q):
    pi, xi = list(map(int, input().split()))
    px[pi - 1] += xi
sp = [0 for i in range(n)]
s = deque()
s.append(0)
visited = [False for i in range(n)]
while len(s) > 0:
    x = s.popleft()
    visited[x] = True
    sp[x] += px[x]
    for xc in d[x]:
        if not visited[xc]:
            s.append(xc)
            sp[xc] += sp[x]
for i in range(n):
    print((sp[i]))

import sys
from collections import deque


def input():
    return sys.stdin.readline()[:-1]


n, q = list(map(int, input().split()))
d = [[] for i in range(n)]
for i in range(n - 1):
    ai, bi = list(map(int, input().split()))
    d[ai - 1].append(bi - 1)
    d[bi - 1].append(ai - 1)
# point
px = [0 for i in range(n)]
for i in range(q):
    pi, xi = list(map(int, input().split()))
    px[pi - 1] += xi
sp = [0 for i in range(n)]
s = deque()
s.append(0)
visited = [False for i in range(n)]
while len(s) > 0:
    x = s.popleft()
    visited[x] = True
    sp[x] += px[x]
    for xc in d[x]:
        if not visited[xc]:
            s.append(xc)
            sp[xc] += sp[x]
for i in range(n):
    print((sp[i]))

+import sys + + +def input(): +    return sys.stdin.readline()[:-1] +