import sys

sys.setrecursionlimit(500000)



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

G = [set() for _ in range(N)]

cnt = [0]*N

visited = [0]*N



def dfs(start_node):

    for i in G[start_node]:

        if visited[i]==0:

            visited[i]=1

            cnt[i] += cnt[start_node]

            dfs(i)



for _ in range(N-1):

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

    a -= 1

    b -= 1

    G[a].add(b)

    G[b].add(a)



for i in range(Q):

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

    node -= 1

    cnt[node] += x



visited[0]=1

#dfs(0)

st = [0]

while st:

    v = st.pop()

    for u in G[v]:

        if visited[u]: continue

        visited[u] = 1

        cnt[u] += cnt[v]

        st.append(u)    



print((*cnt))

import sys

sys.setrecursionlimit(500000)

input = sys.stdin.readline



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

G = [set() for _ in range(N)]

cnt = [0]*N

visited = [0]*N



for _ in range(N-1):

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

    a -= 1

    b -= 1

    G[a].add(b)

    G[b].add(a)



for i in range(Q):

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

    node -= 1

    cnt[node] += x



visited[0]=1

st = [0]

while st:

    v = st.pop()

    for u in G[v]:

        if visited[u]:

            continue

        visited[u] = 1

        cnt[u] += cnt[v]

        st.append(u)    



print((*cnt))
import sys

sys.setrecursionlimit(500000)
N, Q = list(map(int, input().split()))
G = [set() for _ in range(N)]
cnt = [0] * N
visited = [0] * N


def dfs(start_node):
    for i in G[start_node]:
        if visited[i] == 0:
            visited[i] = 1
            cnt[i] += cnt[start_node]
            dfs(i)


for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    G[a].add(b)
    G[b].add(a)
for i in range(Q):
    node, x = list(map(int, input().split()))
    node -= 1
    cnt[node] += x
visited[0] = 1
# dfs(0)
st = [0]
while st:
    v = st.pop()
    for u in G[v]:
        if visited[u]:
            continue
        visited[u] = 1
        cnt[u] += cnt[v]
        st.append(u)
print((*cnt))

import sys

sys.setrecursionlimit(500000)
input = sys.stdin.readline
N, Q = list(map(int, input().split()))
G = [set() for _ in range(N)]
cnt = [0] * N
visited = [0] * N
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    G[a].add(b)
    G[b].add(a)
for i in range(Q):
    node, x = list(map(int, input().split()))
    node -= 1
    cnt[node] += x
visited[0] = 1
st = [0]
while st:
    v = st.pop()
    for u in G[v]:
        if visited[u]:
            continue
        visited[u] = 1
        cnt[u] += cnt[v]
        st.append(u)
print((*cnt))

+input = sys.stdin.readline - - -def dfs(start_node): -    for i in G[start_node]: -        if visited[i] == 0: -            visited[i] = 1 -            cnt[i] += cnt[start_node] -            dfs(i) - - -# dfs(0)