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

n,q=I()

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

d=[0]*n

for _ in range(n-1):

    a,b=I()

    e[a-1]+=b-1,

    e[b-1]+=a-1,

for _ in range(q):

    p,x=I()

    d[p-1]+=x

f=[1]+[0]*n

q=[0]

while q:

    v=q.pop()

    for w in e[v]:

        if f[w]:continue

        f[w]=1

        d[w]+=d[v]

        q+=w,

print((*d))
n,q,*t=list(map(int,open(0).read().split()))

e=[[]for _ in[0]*n]

s=[0]

d=s*n

f=[1]+s*n

for a,b in zip(*[iter(t[:-q-q])]*2):

  e[a-1]+=b-1,

  e[b-1]+=a-1,

for p,x in zip(*[iter(t[-q-q:])]*2):d[p-1]+=x

while s:

  v=s.pop()

  for w in e[v]:

    if f[w]:continue

    f[w]=1

    d[w]+=d[v]

    s+=w,

print((*d))
I = lambda: list(map(int, input().split()))
n, q = I()
e = [[] for _ in range(n)]
d = [0] * n
for _ in range(n - 1):
    a, b = I()
    e[a - 1] += (b - 1,)
    e[b - 1] += (a - 1,)
for _ in range(q):
    p, x = I()
    d[p - 1] += x
f = [1] + [0] * n
q = [0]
while q:
    v = q.pop()
    for w in e[v]:
        if f[w]:
            continue
        f[w] = 1
        d[w] += d[v]
        q += (w,)
print((*d))

n, q, *t = list(map(int, open(0).read().split()))
e = [[] for _ in [0] * n]
s = [0]
d = s * n
f = [1] + s * n
for a, b in zip(*[iter(t[: -q - q])] * 2):
    e[a - 1] += (b - 1,)
    e[b - 1] += (a - 1,)
for p, x in zip(*[iter(t[-q - q :])] * 2):
    d[p - 1] += x
while s:
    v = s.pop()
    for w in e[v]:
        if f[w]:
            continue
        f[w] = 1
        d[w] += d[v]
        s += (w,)
print((*d))

-I = lambda: list(map(int, input().split())) -n, q = I() -e = [[] for _ in range(n)] -d = [0] * n -for _ in range(n - 1): -    a, b = I() +n, q, *t = list(map(int, open(0).read().split())) +e = [[] for _ in [0] * n] +s = [0] +d = s * n +f = [1] + s * n +for a, b in zip(*[iter(t[: -q - q])] * 2): -for _ in range(q): -    p, x = I() +for p, x in zip(*[iter(t[-q - q :])] * 2): -f = [1] + [0] * n -q = [0] -while q: -    v = q.pop() +while s: +    v = s.pop() -        q += (w,) +        s += (w,)