f=lambda:list(map(int,input().split()))

n,q=f()

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

for i in range(n-1):

  a,b=f()

  g[a-1]+=[b-1]

  g[b-1]+=[a-1]

c=[0]*n

for i in range(q): v,x=f(); c[v-1]+=x

b=[1]*n

s=[0]

b[0]=0

while s:

  t=s.pop()

  for i in g[t]:

    if b[i]: c[i]+=c[t]; s+=[i]; b[i]=0

print((*c))
import sys

sys.setrecursionlimit(10**9)

f=lambda:list(map(int,sys.stdin.readline().split()))

n,q=f()

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

for i in range(n-1):

  a,b=f()

  g[a-1]+=[b-1]

  g[b-1]+=[a-1]

c=[0]*n

for i in range(q):

  v,x=f()

  c[v-1]+=x

def dfs(v,p=-1):

  for i in g[v]:

    if i==p: continue

    c[i]+=c[v]

    dfs(i,v)

dfs(0)

print((*c))
f = lambda: list(map(int, input().split()))
n, q = f()
g = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = f()
    g[a - 1] += [b - 1]
    g[b - 1] += [a - 1]
c = [0] * n
for i in range(q):
    v, x = f()
    c[v - 1] += x
b = [1] * n
s = [0]
b[0] = 0
while s:
    t = s.pop()
    for i in g[t]:
        if b[i]:
            c[i] += c[t]
            s += [i]
            b[i] = 0
print((*c))

import sys

sys.setrecursionlimit(10**9)
f = lambda: list(map(int, sys.stdin.readline().split()))
n, q = f()
g = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = f()
    g[a - 1] += [b - 1]
    g[b - 1] += [a - 1]
c = [0] * n
for i in range(q):
    v, x = f()
    c[v - 1] += x


def dfs(v, p=-1):
    for i in g[v]:
        if i == p:
            continue
        c[i] += c[v]
        dfs(i, v)


dfs(0)
print((*c))

-f = lambda: list(map(int, input().split())) +import sys + +sys.setrecursionlimit(10**9) +f = lambda: list(map(int, sys.stdin.readline().split())) -b = [1] * n -s = [0] -b[0] = 0 -while s: -    t = s.pop() -    for i in g[t]: -        if b[i]: -            c[i] += c[t] -            s += [i] -            b[i] = 0 + + +def dfs(v, p=-1): +    for i in g[v]: +        if i == p: +            continue +        c[i] += c[v] +        dfs(i, v) + + +dfs(0)