#!/usr/bin/env python3

import sys

input = lambda: sys.stdin.readline()[:-1]

sys.setrecursionlimit(10**8)

inf = float('inf')

mod = 10**9+7



def dfs(node):

    tmp = data[node]

    for v in G[node]:

        if not visited[v]:

            visited[v]=1

            data[v]+=tmp

            dfs(v)

    return 0







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

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

for i in range(n-1):

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

    a-=1;b-=1

    G[a].append(b)

    G[b].append(a)

data=[0]*n

for i in range(q):

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

    data[p-1]+=x

visited=[0]*n

visited[0]=1

dfs(0)

print((*data))

#!/usr/bin/env python3

import sys

input = lambda: sys.stdin.readline()[:-1]

sys.setrecursionlimit(10**8)

inf = float('inf')

mod = 10**9+7









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

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

for i in range(n-1):

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

    a-=1;b-=1

    G[a].append(b)

    G[b].append(a)

data=[0]*n

for i in range(q):

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

    data[p-1]+=x

visited=[0]*n

visited[0]=1

stack=[0]



while stack:

    node=stack.pop()

    for v in G[node]:

        if not visited[v]:

            visited[v]=1

            data[v]+=data[node]

            stack.append(v)





print((*data))
#!/usr/bin/env python3
import sys

input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)
inf = float("inf")
mod = 10**9 + 7


def dfs(node):
    tmp = data[node]
    for v in G[node]:
        if not visited[v]:
            visited[v] = 1
            data[v] += tmp
            dfs(v)
    return 0


n, q = list(map(int, input().split()))
G = [[] for i in range(n)]
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
data = [0] * n
for i in range(q):
    p, x = list(map(int, input().split()))
    data[p - 1] += x
visited = [0] * n
visited[0] = 1
dfs(0)
print((*data))

#!/usr/bin/env python3
import sys

input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)
inf = float("inf")
mod = 10**9 + 7
n, q = list(map(int, input().split()))
G = [[] for i in range(n)]
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
data = [0] * n
for i in range(q):
    p, x = list(map(int, input().split()))
    data[p - 1] += x
visited = [0] * n
visited[0] = 1
stack = [0]
while stack:
    node = stack.pop()
    for v in G[node]:
        if not visited[v]:
            visited[v] = 1
            data[v] += data[node]
            stack.append(v)
print((*data))

- - -def dfs(node): -    tmp = data[node] -    for v in G[node]: -        if not visited[v]: -            visited[v] = 1 -            data[v] += tmp -            dfs(v) -    return 0 - - -dfs(0) +stack = [0] +while stack: +    node = stack.pop() +    for v in G[node]: +        if not visited[v]: +            visited[v] = 1 +            data[v] += data[node] +            stack.append(v)