CodeEff/ECCO huggingface dataset:
# Original solution
import sys
sys.setrecursionlimit(10**6)

N,Q = [int(i) for i in input().split()] #N個の頂点、Q回の操作
aaabbb = [[int(i) for i in input().split()] for j in range(N-1)] #木の辺
pppxxx = [[int(i) for i in input().split()] for j in range(Q)] #操作

tree = [[] for i in range(N+1)]

for a,b in aaabbb:
    tree[a].append(b)
    tree[b].append(a)

#print(tree)

counter = [0 for i in range(N+1)]

for p,x in pppxxx:
    counter[p] += x

#print(counter)

def dfs(pos,parent,add):
    counter[pos] += add
    for next_pos in tree[pos]:
        if not next_pos == parent:
            dfs(next_pos,pos,counter[pos])

dfs(1,0,0)

#print(counter)

print((" ".join([str(i) for i in counter[1:]])))

# Optimized solution
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N,Q = [int(i) for i in input().split()] #N個の頂点、Q回の操作
aaabbb = [[int(i) for i in input().split()] for j in range(N-1)] #木の辺
pppxxx = [[int(i) for i in input().split()] for j in range(Q)] #操作

tree = [[] for i in range(N+1)]

for a,b in aaabbb:
    tree[a].append(b)
    tree[b].append(a)

#print(tree)

counter = [0 for i in range(N+1)]

for p,x in pppxxx:
    counter[p] += x

#print(counter)

def dfs(pos,parent,add):
    counter[pos] += add
    for next_pos in tree[pos]:
        if not next_pos == parent:
            dfs(next_pos,pos,counter[pos])

dfs(1,0,0)

#print(counter)

print((" ".join([str(i) for i in counter[1:]])))
# Original solution
# ki
from collections import deque

# input

n, q = list(map(int, input().split()))
ln = [list(map(int, input().split())) for i in range(n-1)]
lq = [list(map(int, input().split())) for i in range(q)]

edge = [[] for i in range(n+1)]

for next in ln:
    parent = next[0]
    child = next[1]
    edge[parent].append(child)
    edge[child].append(parent)


score = [0]*(n+1)
visited = [False]*(n+1)

for q in lq:
    score[q[0]] += q[1]

que = deque()
que.append(1)

while que:
    node = que.popleft()
    if not visited[node]:
        visited[node] = True
        for next in edge[node]:
            if not visited[next]:
                score[next] += score[node]
                que.append(next)

print((" ".join([str(n) for n in score][1:])))


# Optimized solution
# ki
from collections import deque

# input

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

edge = [[] for i in range(n+1)]
for i in range(n-1):
    a, b = list(map(int, input().split()))
    edge[a].append(b)
    edge[b].append(a)

lq = [list(map(int, input().split())) for i in range(q)]

score = [0]*(n+1)
visited = [False]*(n+1)

for q in lq:
    score[q[0]] += q[1]

que = deque()
que.append(1)

while que:
    node = que.popleft()
    if not visited[node]:
        visited[node] = True
        for next in edge[node]:
            if not visited[next]:
                score[next] += score[node]
                que.append(next)

print((" ".join([str(n) for n in score][1:])))
# Original solution
import sys

sys.setrecursionlimit(10000000)

class tree:
    def __init__(self):
        self.baby_list=[]
        self.counter=0
    
    def add_value(self, value):
        self.counter += value
        for i in self.baby_list:
            hoge[i].add_value(value)

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


hoge={}

for i in range(1,N+1):
    hoge[i] = tree()
    
for i in range(N-1):
    a,b=list(map(int, input().split() ))
    hoge[a].baby_list.append(b)

for i in range(Q):
    root, value = list(map(int, input().split() ))
    hoge[root].add_value(value)

output = []
for t in hoge:
    output.append(hoge[t].counter)

output = list(map(str, output))
print((" ".join(output)))

# Optimized solution
import sys

sys.setrecursionlimit(10000000)

class tree:
    def __init__(self):
        self.baby_list=[]
        self.counter=0
    
    def add_value(self):
        for i in self.baby_list:
            hoge[i].counter += self.counter
            hoge[i].add_value()

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


hoge={}

for i in range(1,N+1):
    hoge[i] = tree()
    
for i in range(N-1):
    a,b=list(map(int, input().split() ))
    hoge[a].baby_list.append(b)

for i in range(Q):
    root, value = list(map(int, input().split() ))
    hoge[root].counter+=value

hoge[1].add_value()
output = []
for t in hoge:
    output.append(hoge[t].counter)

output = list(map(str, output))
print((" ".join(output)))
# Original solution
import sys
from collections import deque

class tree:
    def __init__(self):
        self.baby_list=deque()
        self.counter=0
    
    def add_value(self):
        for i in self.baby_list:
            hoge[i].counter+=self.counter
            hoge[i].add_value()
            
N,Q=list(map(int, input().split() ))

hoge={i:tree() for i in range(1,N+1)}
    
for i in range(N-1):
    a,b=list(map(int, input().split() ))
    hoge[a].baby_list.append(b)

for i in range(Q):
    root, value = list(map(int, input().split() ))
    hoge[root].counter+=value

hoge[1].add_value()
output = []
for t in hoge:
    output.append(hoge[t].counter)

    
output = list(map(str, output))
print((" ".join(output)))

# Optimized solution
import sys

sys.setrecursionlimit(10000000)


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

data={i+1:0 for i in range(N)}

# for i in range(N-1):
#     a,b=list(map(int, input().split() ))
#     hoge[a].baby_list.append(b)

relate = [list(map(int, input().split() )) for i in range(N-1)]
relate.sort(key=lambda x :x[0])
    
for i in range(Q):
    root, value = list(map(int, input().split() ))
    data[root]+=value

for a,b in relate:
    data[b]+=data[a]

print((" ".join(list(map(str,list(data.values()))))))
# Original solution
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

sys.setrecursionlimit(50000000)

class check():
    def __init__(self):
        readline=sys.stdin.readline
        n,q=list(map(int, readline().rstrip().split()))
        self.tree=[[] for i in range(n)]
        self.ans=[0]*n
        for i in range(n-1):
            a,b=list(map(int, readline().rstrip().split()))
            a-=1
            b-=1
            self.tree[a].append(b)
            self.tree[b].append(a)
        for i in range(q):
            p,x=list(map(int, readline().rstrip().split()))
            p-=1
            self.ans[p]+=x
    def do(self,root,next):
        if root >= 0:
            self.ans[next]+=self.ans[root]
        for a in self.tree[next]:
            if a==root:
                continue
            self.do(next,a)
    def answer(self):
        print((" ".join(map(str,self.ans))))

def resolve():
    readline=sys.stdin.readline

    dfs=check()
    dfs.do(-1,0)
    dfs.answer()

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------


# Optimized solution
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

sys.setrecursionlimit(50000000)

def do(root,next,tree,ans):
    if root >= 0:
        ans[next]+=ans[root]
    for a in tree[next]:
        if a==root:
            continue
        do(next,a,tree,ans)

def resolve():
    readline=sys.stdin.readline
    n,q=list(map(int, readline().rstrip().split()))
    tree=[[] for i in range(n)]
    ans=[0]*n
    for i in range(n-1):
        a,b=list(map(int, readline().rstrip().split()))
        a-=1
        b-=1
        tree[a].append(b)
        tree[b].append(a)
    for i in range(q):
        p,x=list(map(int, readline().rstrip().split()))
        p-=1
        ans[p]+=x
    do(-1,0,tree,ans)
    print((" ".join(map(str,ans))))

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------
# Original solution
from heapq import heappush, heappop, heapify, heapreplace
from collections import defaultdict
from bisect import bisect_left


class Solution:
    def main(self):
        path = defaultdict(list)
        N, Q = list(map(int, input().split()))
        freq = [0] * N
        for i in range(N-1):
            ai, bi = list(map(int, input().split()))
            path[ai-1].append(bi-1)
            # path[bi-1].append(ai-1)

        for i in range(Q):
            p, x = list(map(int, input().split()))
            freq[p-1] += x

        stack = [(0, 0)]
        seen = set()
        res = [0] * N
        while stack:
            node, cum = stack.pop(0)
            # seen.add(node)
            val = freq[node] + cum
            res[node] = val
            for other in path[node]:
                # if other not in seen:
                stack.append((other, val))
        print((' '.join(map(str, res))))

if __name__ == '__main__':
    Solution().main()

# Optimized solution
from heapq import heappush, heappop, heapify, heapreplace
from collections import defaultdict
from bisect import bisect_left


class Solution:
    def main(self):
        path = defaultdict(list)
        N, Q = list(map(int, input().split()))
        freq = [0] * N
        for i in range(N-1):
            ai, bi = list(map(int, input().split()))
            path[ai-1].append(bi-1)
            # path[bi-1].append(ai-1)

        for i in range(Q):
            p, x = list(map(int, input().split()))
            freq[p-1] += x

        stack = [(0, 0)]
        seen = set()
        res = freq[:]
        for i in range(N):
            for other in path[i]:
                res[other] += res[i]

        print((' '.join(map(str, res))))


if __name__ == '__main__':
    Solution().main()
# Original solution
import sys
sys.setrecursionlimit(10 ** 9)

input = sys.stdin.readline

n, q = map(int, input().split())
edges = [[] for _ in range(n)]
cnt = [0 for _ in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
for i in range(q):
    p, x = map(int, input().split())
    cnt[p - 1] += x

ans = [0 for _ in range(n)]
visit = [False for _ in range(n)]

def rec(pos, val):
    val += cnt[pos]
    ans[pos] = val
    for to in edges[pos]:
        if not visit[to]:
            visit[to] = True
            rec(to, val)

visit[0] = True
rec(0, 0)
for x in ans[:-1]:
    print(x, end=' ')
print(ans[-1])


# Optimized solution
import sys
sys.setrecursionlimit(10 ** 9)

input = sys.stdin.readline

n, q = map(int, input().split())
edges = [[] for _ in range(n)]
cnt = [0 for _ in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
for i in range(q):
    p, x = map(int, input().split())
    cnt[p - 1] += x

ans = [0 for _ in range(n)]

visit = [False for _ in range(n)]
visit[0] = True

stack = []
stack.append((0, 0))

while stack:
    pos, val = stack.pop(-1)
    val += cnt[pos]
    ans[pos] = val
    for to in edges[pos]:
        if not visit[to]:
            visit[to] = True
            stack.append((to, val))

for x in ans[:-1]:
    print(x, end=' ')
print(ans[-1])
# Original solution
import sys
sys.setrecursionlimit(10 ** 9)
n,q=list(map(int,input().split()))
graph=[[] for _ in range(n+1)]
ab=[list(map(int,input().split())) for _ in range(n-1)]
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)
px=[list(map(int,input().split())) for _ in range(q)]
seen=[0]*(n+1)
ans=[0]*(n+1)
for p,x in px:
    ans[p]+=x
def dfs(i):
    seen[i]=1
    for li in graph[i]:
        if seen[li]==0:
            ans[li]+=ans[i]
            dfs(li)
dfs(1)
print((' '.join(map(str,ans[1:]))))

# Optimized solution
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
def main():
    n,q=list(map(int,input().split()))
    graph=[[] for _ in range(n+1)]
    ab=[list(map(int,input().split())) for _ in range(n-1)]
    for a,b in ab:
        graph[a].append(b)
        graph[b].append(a)
    px=[list(map(int,input().split())) for _ in range(q)]
    seen=[0]*(n+1)
    ans=[0]*(n+1)
    for p,x in px:
        ans[p]+=x
    def dfs(i):
        seen[i]=1
        for li in graph[i]:
            if seen[li]==0:
                ans[li]+=ans[i]
                dfs(li)
    dfs(1)
    print((' '.join(map(str,ans[1:]))))
if __name__ == '__main__':
    main()
# Original solution
def main(n,ab,px):
  import sys
  sys.setrecursionlimit(10**7)

  g=[[]for _ in range(n)]
  for a,b in ab:
    g[a-1].append(b-1)
    g[b-1].append(a-1)
  ans=[0]*n
  for p,x in px:
    ans[p-1]+=x
  
  def dfs(seen,i):
    seen[i]=1
    l=g[i]
    for li in [li for li in l if seen[li]==0]:
      ans[li]+=ans[i]
      dfs(seen,li)
  seen=[0]*n
  dfs(seen,0)
  print((' '.join(list(map(str,ans)))))

if __name__=='__main__':
  import sys
  input = sys.stdin.readline
  n,q=list(map(int,input().split()))
  ab=[list(map(int,input().split())) for _ in range(n-1)]
  px=[list(map(int,input().split())) for _ in range(q)]
  main(n,ab,px)
  

# Optimized solution
def main(n,ab,px):
  import sys
  sys.setrecursionlimit(10**7)
  g=[[]for _ in range(n)]
  for a,b in ab:
    g[a-1].append(b-1)
    g[b-1].append(a-1)
  ans=[0 for _ in range(n)]
  for p,x in px:
    ans[p-1]+=x  
  def dfs(seen,i):
    seen[i]=1
    l=g[i]
    for li in [li for li in l if seen[li]==0]:
      ans[li]+=ans[i]
      dfs(seen,li)
  seen=[0 for _ in range(n)]
  dfs(seen,0)
  print((' '.join(list(map(str,ans)))))

if __name__=='__main__':
  import sys
  input = sys.stdin.readline
  n,q=list(map(int,input().split()))
  ab=[list(map(int,input().split())) for _ in range(n-1)]
  px=[list(map(int,input().split())) for _ in range(q)]
  main(n,ab,px)
# Original solution
def main(n,ab,px):
  import sys
  sys.setrecursionlimit(10**7)
  g=[[]for _ in range(n)]
  for a,b in ab:
    g[a-1].append(b-1)
    g[b-1].append(a-1)
  ans=[0 for _ in range(n)]
  for p,x in px:
    ans[p-1]+=x  
  def dfs(seen,i):
    seen[i]=1
    l=g[i]
    for li in [li for li in l if seen[li]==0]:
      ans[li]+=ans[i]
      dfs(seen,li)
  seen=[0 for _ in range(n)]
  dfs(seen,0)
  print((' '.join(list(map(str,ans)))))

if __name__=='__main__':
  import sys
  input = sys.stdin.readline
  n,q=list(map(int,input().split()))
  ab=[list(map(int,input().split())) for _ in range(n-1)]
  px=[list(map(int,input().split())) for _ in range(q)]
  main(n,ab,px)
  

# Optimized solution
import sys
input = sys.stdin.readline
import sys
sys.setrecursionlimit(10**7)
def main(n,ab,px):
  g=[[]for _ in range(n)]
  for a,b in ab:
    g[a-1].append(b-1)
    g[b-1].append(a-1)
  ans=[0 for _ in range(n)]
  for p,x in px:
    ans[p-1]+=x  
  def dfs(seen,i):
    seen[i]=1
    for li in g[i]:
      if seen[li]==0:
        ans[li]+=ans[i]
        dfs(seen,li)
  seen=[0 for _ in range(n)]
  dfs(seen,0)
  print((' '.join(list(map(str,ans)))))

if __name__=='__main__':
  n,q=list(map(int,input().split()))
  ab=[list(map(int,input().split())) for _ in range(n-1)]
  px=[list(map(int,input().split())) for _ in range(q)]
  main(n,ab,px)
# Original solution
import sys
sys.setrecursionlimit(200005)
n, q = list(map(int, input().split()))

to = [[] for i in range(n+1)]


for i in range(n-1):
    a, b = list(map(int, input().split()))
    to[a].append(b)
    to[b].append(a)

score = [0]*(n+1)
for i in range(q):
    p, x = list(map(int, input().split()))
    score[p] += x


def down_tree(index, parent):
    for i in to[index]:
        if i == parent:
            continue
        score[i] += score[index]
        down_tree(i, index)



down_tree(1, 1)

print((' '.join(map(str, score[1:]))))

# Optimized solution
import sys
input = sys.stdin.readline
sys.setrecursionlimit(200005)
n, q = list(map(int, input().split()))

to = [[] for i in range(n+1)]


for i in range(n-1):
    a, b = list(map(int, input().split()))
    to[a].append(b)
    to[b].append(a)

score = [0]*(n+1)
for i in range(q):
    p, x = list(map(int, input().split()))
    score[p] += x


def down_tree(index, parent):
    for i in to[index]:
        if i == parent:
            continue
        score[i] += score[index]
        down_tree(i, index)



down_tree(1, 1)

print((' '.join(map(str, score[1:]))))
# Original solution
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
N, Q = list(map(int, input().split()))
link = [[0]*(N+1) for _ in range(N+1)]
for n in range(N-1):
    a, b = list(map(int, input().split()))
    link[a][b] = 1
    link[b][a] = 1
V = [0] * (N+1)
ans = [0] * (N+1)
for q in range(Q):
    p, x = list(map(int, input().split()))
    V[p] += x

def dfs(i, parent, acc):
    V[i] += acc
    for j in range(1,N+1):
        if link[i][j] == 1 and parent!=j:
            dfs(j,i,V[i])
cur = 1
parent = 0
acc = 0

dfs(cur, parent , acc)
V = [str(v) for v in V]
print((" ".join(V[1:])))


# Optimized solution
import sys
input = sys.stdin.readline
sys.setrecursionlimit(int(1E+7))
def main():
    N, Q = list(map(int, input().split()))
    link = [[] for _ in range(N+1)]
    for n in range(N-1):
        a, b = list(map(int, input().split()))
        link[a].append(b)
        link[b].append(a)
    V = [0] * (N+1)
    ans = [0] * (N+1)
    for q in range(Q):
        p, x = list(map(int, input().split()))
        V[p] += x

    def dfs(i, parent, acc):
        V[i] += acc
        for j in link[i]:
            if j != parent:
                dfs(j,i,V[i])
    cur = 1
    parent = 0
    acc = 0
    dfs(cur, parent , acc)
    V = [str(v) for v in V]
    print((" ".join(V[1:])))

if __name__ == '__main__':
    main()
# Original solution
import sys
sys.setrecursionlimit(10**6)
N,Q=list(map(int,input().split()))
L=[[] for _ in range(N)]
for _ in range(N-1):
    a,b=list(map(int,input().split()))
    a-=1
    b-=1
    L[a].append(b)
    L[b].append(a)
CL=[0]*N
for _ in range(Q):
    p,x=list(map(int,input().split()))
    CL[p-1]+=x

AL=[0]*N
ed=[0]*N
def dfs(val, now):
    ed[now]=1
    val+=CL[now]
    AL[now]=val
    for p in L[now]:
        if ed[p]==0:
            dfs(val,p)
dfs(0,0)
print((" ".join(map(str,AL))))

# Optimized solution
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)
N,Q=list(map(int,input().split()))
L=[[] for _ in range(N)]
for _ in range(N-1):
    a,b=list(map(int,input().split()))
    a-=1
    b-=1
    L[a].append(b)
    L[b].append(a)
CL=[0]*N
for _ in range(Q):
    p,x=list(map(int,input().split()))
    CL[p-1]+=x

AL=[0]*N
ed=[0]*N
q=[(0,0)]
while len(q)!=0:
    now,val=q.pop(-1)
    ed[now] = 1
    val += CL[now]
    AL[now] = val
    for p in L[now]:
        if ed[p] == 0:
            q.append((p,val))
print((" ".join(map(str,AL))))
# Original solution
n, q = list(map(int,input().split()))
ikeru = [[] for _ in range(n)]
for i in range(n-1):
	a, b = list(map(int, input().split()))
	ikeru[a-1].append(b-1)
	ikeru[b-1].append(a-1)

fukasa = [0 for _ in range(n)]
fukasamoto = [set([]) for _ in range(n)]
fukasamoto[0].add(0)
kaisuu = 0
settansaku = set([])
setmada = {0}
kouho = 1

while kouho != 0:
	kaisuu += 1
	for i in list(setmada):
		settansaku.add(i)
		setmada.remove(i)
		kouho -= 1
		for k in ikeru[i]:
			if not k in setmada:
				if not k in settansaku:
					setmada.add(k)
					kouho += 1
					fukasa[k] = kaisuu
					fukasamoto[k] = fukasamoto[i] | {i, k}

kasan = [0 for _ in range(n)]
for i in range(q):
	p, x = list(map(int,input().split()))
	kasan[p-1] += x

ansl = [0 for _ in range(n)]
for i in range(n):
	tmpans = 0
	for j in fukasamoto[i]:
		tmpans += kasan[j]
	ansl[i] = tmpans

print((" ".join([str(ansl[i]) for i in range(n)])))

# Optimized solution
n, q = list(map(int,input().split()))
ikeru = [[] for _ in range(n)]
for i in range(n-1):
	a, b = list(map(int, input().split()))
	ikeru[a-1].append(b-1)
	ikeru[b-1].append(a-1)

kasan = [0 for _ in range(n)]
for i in range(q):
	p, x = list(map(int,input().split()))
	kasan[p-1] += x

ansl = [0 for _ in range(n)]
ansl[0] = kasan[0]
kaisuu = 0
settansaku = set([])
setmada = {0}
kouho = 1

while kouho != 0:
	kaisuu += 1
	for i in list(setmada):
		settansaku.add(i)
		setmada.remove(i)
		kouho -= 1
		for k in ikeru[i]:
			if not k in setmada:
				if not k in settansaku:
					setmada.add(k)
					kouho += 1
					ansl[k] = ansl[i] + kasan[k]

print((" ".join([str(ansl[i]) for i in range(n)])))
# Original solution
N, Q = list(map(int, input().split()))

ab = [list(map(int, input().split())) for _ in range(N - 1)]
px = [list(map(int, input().split())) for _ in range(Q)]

graph = [[] for _ in range(N)]
for i, (ai, bi) in enumerate(ab):
    graph[ai - 1].append(bi - 1)
    graph[bi - 1].append(ai - 1)

from collections import deque
    
c = [0] * N
for j, (pj, xj) in enumerate(px):
    c[pj - 1] += xj
    
ans = [None] * N
q_0 = deque([(0, 0)])
while len(q_0) > 0:
    score, src = q_0.popleft()
    # print("#", score, src)
    score_tmp = score + c[src]
    ans[src] = score_tmp
    for dst in graph[src]:
        if ans[dst] == None:
            q_0.append((score_tmp, dst))

print((' '.join(map(str, ans))))

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

# ab = [list(map(int, input().split())) for _ in range(N - 1)]
# px = [list(map(int, input().split())) for _ in range(Q)]

# graph = [[] for _ in range(N)]
# for i, (ai, bi) in enumerate(ab):
#     graph[ai - 1].append(bi - 1)
#     graph[bi - 1].append(ai - 1)

from collections import deque
    
# c = [0] * N
# for j, (pj, xj) in enumerate(px):
#     c[pj - 1] += xj

graph = [[] for _ in range(N)]
for _ in range(N - 1):
    ai, bi = list(map(int, input().split()))
    graph[ai - 1].append(bi - 1)
    graph[bi - 1].append(ai - 1)
    
c = [0] * N
for _ in range(Q):
    pj, xj = list(map(int, input().split()))
    c[pj - 1] += xj
    
ans = [None] * N
q_0 = deque([(0, 0)])
while len(q_0) > 0:
    score, src = q_0.popleft()
    # print("#", score, src)
    score_tmp = score + c[src]
    ans[src] = score_tmp
    for dst in graph[src]:
        if ans[dst] == None:
            q_0.append((score_tmp, dst))

print((' '.join(map(str, ans))))
# Original solution
import sys
sys.setrecursionlimit(10**6)
def main():
    N, Q = list(map(int, input().split()))
    E = [[] for i in range(N+1)]
    counter = [0] * (N+1)

    for i in range(N-1):
        a, b = list(map(int, input().split()))
        E[a].append(b)
        E[b].append(a)

    for i in range(Q):
        # 頂点p を根とする部分木に含まれるカウンターにxを足す
        p, x = list(map(int, input().split()))
        counter[p] += x

    queue = []

    parent = [1]
    def mktree(v, parent, E):
        children = E[v]
        children.remove(parent)
        for child in children:
            mktree(child, v, E)

    while parent:
        p = parent.pop()
        for child in E[p]:
            E[child].remove(p)
            parent.append(child)

    def get(v, children, counter):
        c = counter[v]
        for child in children[v]:
            counter[child] += c
            get(child, children, counter)
    """
    parent = [1]
    while parent:
        p = parent.pop()
        c = counter[p]
        for child in E[p]:
            counter[child] += c
            parent.append(child)
    """
    get(1, E, counter)
    print((" ".join(str(x) for x in counter[1:])))

main()






# Optimized solution
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

def main():
    N, Q = list(map(int, input().split()))
    E = [[] for i in range(N+1)]
    counter = [0] * (N+1)

    for i in range(N-1):
        a, b = list(map(int, input().split()))
        E[a].append(b)
        E[b].append(a)

    for i in range(Q):
        # 頂点p を根とする部分木に含まれるカウンターにxを足す
        p, x = list(map(int, input().split()))
        counter[p] += x

    queue = []

    parent = [1]
    def mktree(v, parent, E):
        children = E[v]
        children.remove(parent)
        for child in children:
            mktree(child, v, E)

    while parent:
        p = parent.pop()
        for child in E[p]:
            E[child].remove(p)
            parent.append(child)

    def get(v, children, counter):
        c = counter[v]
        for child in children[v]:
            counter[child] += c
            get(child, children, counter)
    """
    parent = [1]
    while parent:
        p = parent.pop()
        c = counter[p]
        for child in E[p]:
            counter[child] += c
            parent.append(child)
    """
    get(1, E, counter)
    print((" ".join(str(x) for x in counter[1:])))

main()