CodeEff/ECCO huggingface dataset:
# Original solution
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
from collections import deque
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, Q = list(map(int, readline().split()))

    path = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = list(map(int, readline().split()))
        path[a-1].append(b-1)
        path[b-1].append(a-1)

    child = [[] for _ in range(N)]
    child[0] = path[0]
    used = [False] * N
    used[0] = True
    que = deque(child[0])
    while que:
        x = que.popleft()
        used[x] = True
        for a in path[x]:
            if used[a]:
                continue
            else:
                child[x].append(a)
                que.append(a)

    counter = [0]*N
    for _ in range(Q):
        p, x = list(map(int, readline().split()))
        que.append(p-1)
        counter[p-1] += x
        while que:
            a = que.popleft()
            for b in child[a]:
                counter[b] += x
                que.append(b)
    print((' '.join(map(str, counter))))

if __name__ == '__main__':
    main()



# Optimized solution
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
from collections import deque
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, Q = list(map(int, readline().split()))
    AB = list(list(map(int, readline().split())) for _ in range(N-1))
    PX = list(list(map(int, readline().split())) for _ in range(Q))

    graph = [[] for _ in range(N)]
    for a, b in AB:
        graph[a-1].append(b-1)
        graph[b-1].append(a-1)

    value = [0] * N
    for p, x in PX:
        value[p-1] += x

    que = deque([0])
    visited = [False]*N
    while que:
        x = que.popleft()
        visited[x] = True
        for y in graph[x]:
            if visited[y]:
                continue
            else:
                value[y] += value[x]
                que.append(y)
    print((' '.join(map(str, value))))


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

def cur(x):
    for i in neighbor[x]:
        ans[i]+=ans[x]
        neighbor[i].remove(x)
        cur(i)

n,q=list(map(int,input().split()))
neighbor=[[]  for _ in range(n+1)]
ans=[0]*(n+1)
for _ in range(n-1):
    a,b=list(map(int,input().split()))
    neighbor[a].append(b)
    neighbor[b].append(a)


for _ in range(q):
    p,x=list(map(int,input().split()))
    ans[p]+=x

cur(1)
print((" ".join(map(str,ans[1:]))))


# Optimized solution
n,q=list(map(int,input().split()))
neighbor=[[]  for _ in range(n+1)]
ans=[0]*(n+1)

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


for _ in range(q):
    p,x=list(map(int,input().split()))
    ans[p]+=x

visit=[True]*(n+1)
tmp=[1]
for x in tmp:
    visit[x]=False
    for y in neighbor[x]:
        if visit[y]:
            tmp.append(y)
            ans[y]+=ans[x]

print((" ".join(map(str,ans[1:]))))
# Original solution
import sys
sys.setrecursionlimit(10000000)
N,Q=list(map(int, input().split()))
tree_dist={}
for i in range(N):
    tree_dist[i+1] = []
for i in range(N-1):
    a,b = list(map(int, input().split()))
    tree_dist[a].append(b)
    tree_dist[b].append(a)
    
z=[0]*N
for i in range(Q):
    p,x = list(map(int, input().split()))
    z[p-1] += x

def saiki(i,p):
    L = list(tree_dist[i])
    for l in L:
        if l != p:
            z[l-1] += z[i-1]
            saiki(l,i)
saiki(1,0)
print((" ".join(map(str,z))))




# Optimized solution
import sys
sys.setrecursionlimit(10000000)
input=lambda :sys.stdin.readline()
N,Q=list(map(int, input().split()))
tree_dist={}
for i in range(N):
    tree_dist[i+1] = []
for i in range(N-1):
    a,b = list(map(int, input().split()))
    tree_dist[a].append(b)
    tree_dist[b].append(a)
    
z=[0]*N
for i in range(Q):
    p,x = list(map(int, input().split()))
    z[p-1] += x

def saiki(i,p):
    L = list(tree_dist[i])
    for l in L:
        if l != p:
            z[l-1] += z[i-1]
            saiki(l,i)
saiki(1,0)
print((" ".join(map(str,z))))
# Original solution
from collections import deque

N,Q = list(map(int, input().split()))
g = [[] for i in range(N)]
q,s,c = [0]*N,[False]*N,[0]*N
d = deque()

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

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

d.append(0)
while d:
	v = d.popleft()
	s[v] = True
	for x in g[v]:
		if not s[x]:
			d.append(x)
			q[x] += q[v]

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

# Optimized solution
from collections import deque

N,Q = list(map(int, input().split()))
g,q,s,c,d = [[] for i in range(N)],[0]*N,[False]*N,[0]*N,deque()

for _ in range(N-1):
	a,b = [int(x)-1 for x in input().split()]
	g[a].append(b)
	g[b].append(a)

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

d.append(0)
while d:
	v = d.popleft()
	s[v] = True
	for x in g[v]:
		if not s[x]:
			d.append(x)
			q[x] += q[v]

print((' '.join(map(str,q))))
# Original solution
from sys import setrecursionlimit
setrecursionlimit(10**6)

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

def update(v, p):
    for next in tree[v]:
        if next == p:
            continue
        counter[next] += counter[v]
        update(next, v)

tree = [[] for _ in range(N)]
counter = [0] * N

for _ in range(N-1):
    a, b = list(map(int, input().split()))
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
for _ in range(Q):
    p, x = list(map(int, input().split()))
    counter[p-1] += x
update(0, -1)
print((" ".join(map(str, counter))))


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

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

def update(v, p):
    for next in tree[v]:
        if next == p:
            continue
        counter[next] += counter[v]
        update(next, v)

tree = [[] for _ in range(N)]
counter = [0] * N

for _ in range(N-1):
    a, b = list(map(int, input().split()))
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
for _ in range(Q):
    p, x = list(map(int, input().split()))
    counter[p-1] += x
update(0, -1)
print((" ".join(map(str, counter))))
# Original solution
N,Q = list(map(int,input().split()))
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x
    
q = [(1,0)]
while q:
    x,parent = q.pop()
    value[x] += value[parent]
    for y in graph[x]:
        if y == parent:
            continue
        q.append((y,x))

answer = ' '.join(map(str,value[1:]))
print(answer)


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

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

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x
    
q = [(1,0)]
while q:
    x,parent = q.pop()
    value[x] += value[parent]
    for y in graph[x]:
        if y == parent:
            continue
        q.append((y,x))

answer = ' '.join(map(str,value[1:]))
print(answer)
# Original solution
n, q = list(map(int, input().split()))

# 各ノードのリンクを記録
link_dict = dict()
keys = []
for i in range(n-1):
  a,b = list(map(int, input().split()))
  if a in keys:
    link_dict[str(a-1)].add(b)
  else:
    keys.append(a)
    link_dict[str(a-1)] = {b}
  
# 各ノードの部分木の全てのノードをリストアップ
link_set = [set() for i in range(n-1)]
for i in sorted(keys, reverse=True):
  link_set[int(i) - 1] = set(link_dict[str(i-1)])
  if int(i) < n - 1:
    for j in link_dict[str(int(i) - 1)]:
      if j < n - 1:
        link_set[i - 1] = link_set[i - 1] | link_set[j - 1]

# カウンターの計算を実施
counters = [0] * n
for i in range(q):
  p, x = list(map(int, input().split()))
  counters[p - 1] += x
  
children_counters = [0] * n
for i in range(0, n-1):
  for node in link_set[i]:
    children_counters[node - 1] += counters[i]
str_counters = [str(counters[i] + children_counters[i]) for i in range(n)]
print((' '.join(str_counters)))

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

# 各ノードのリンクを記録
link_set = [set() for _ in range(n-1)]
for i in range(n-1):
  a, b = list(map(int, input().split()))
  link_set[a - 1].add(b)

# カウンターの計算を実施 (O(QN)の計算を避けることがポイント)

## O(Q)の計算
counters = [0] * n
for i in range(q):
  p, x = list(map(int, input().split()))
  counters[p - 1] += x
  
## O(N)の計算
for i in range(n - 1):
  for node in link_set[i]:
    counters[node - 1] += counters[i]

str_counters = [str(c) for c in counters]
print((' '.join(str_counters)))
# Original solution
# 2019-11-17 10:52:21(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    n, q = [int(x) for x in sys.stdin.readline().split()]
    AB = [[] for _ in range(n+1)]
    for _ in range(n-1):
        a, b = [int(x) for x in sys.stdin.readline().split()]
        AB[a].append(b)
        AB[b].append(a)
    # 無向グラフとして考える

    ans = [0 for _ in range(n+1)]
    for _ in range(q):
        p, x = [int(x) for x in sys.stdin.readline().split()]
        ans[p] += x
    
    stack = [1]
    parent = [0 for _ in range(n+1)]
    while stack:
        x = stack.pop()
        for y in AB[x]:
            if y != parent[x]: # yがxの親でなければ
                parent[y] = x # xがyの親
                stack.append(y)
                ans[y] += ans[x]
 
    
    print((' '.join(map(str, ans[1:]))))

if __name__ == "__main__":
    main()



# Optimized solution
import sys

n, q = map(int, sys.stdin.readline().split())
g = [[] for _ in range(n+1)]
for _ in range(n-1):
    a, b = map(int, sys.stdin.readline().split())
    g[a].append(b)
    g[b].append(a)

px = zip(*[map(int, sys.stdin.read().split())] * 2)

def main():
    value = [0] * (n + 1)
    for p, x in px:
        value[p] += x
    
    stack = [1]
    par = [None] * (n + 1)
    while stack:
        u = stack.pop()
        for v in g[u]:
            if v != par[u]:
                par[v] = u
                value[v] += value[u]
                stack.append(v)
    
    return value[1:]
    
if __name__ == '__main__':
    ans = main()
    print(*ans, sep=' ')
# Original solution
# 早くなるおまじない
import sys
input = sys.stdin.buffer.readline

# 再帰関数の呼び出し制限
sys.setrecursionlimit(10**6)

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

dic = {}
for i in range(n-1):
    aa, bb = map(int,input().split())

    if aa not in dic:
        dic[aa] = set()
        dic[aa].add(bb)
    else:
        dic[aa].add(bb)

    if bb not in dic:
        dic[bb] = set()
        dic[bb].add(aa)
    else:
        dic[bb].add(aa)


p = []
x = []
for _ in range(q):
    s, t = map(int,input().split())
    p.append(s)
    x.append(t)

res = [0]*n
for i in range(q):
    res[p[i]-1] += x[i]

visited = set()

# 深さが一つ前のやつのresの値を足す
# dfsはおk，ここで累積和を使う発想が出てこなかった
def dfs(node, prev):
    visited.add(node)
    if prev != 0:
        res[node-1] += res[prev-1]
    for i in dic[node]:
        if i not in visited:
            prev = node
            dfs(i, prev)

dfs(1, 0)
print(*res, sep=" ")


# Optimized solution
# 早くなるおまじない
import sys
input = sys.stdin.buffer.readline

# 再帰関数の呼び出し制限
sys.setrecursionlimit(3 * 10 ** 5)

# 深さが一つ前のやつのresの値を足す
# dfsはおk，ここで累積和を使う発想が出てこなかった
# def dfs(node, prev):
#     visited.add(node)
#     if prev != 0:
#         res[node-1] += res[prev-1]
#     for i in dic[node]:
#         if i not in visited:
#             prev = node
#             dfs(i, prev)

def dfs(node, prev, visited, res, dic):
    visited.add(node)
    if prev != 0:
        res[node-1] += res[prev-1]
    for i in dic[node]:
        if i not in visited:
            prev = node
            dfs(i, prev, visited, res, dic)


def main():
    n,q = map(int,input().split())

    dic = {}
    for i in range(n-1):
        aa, bb = map(int,input().split())

        if aa not in dic:
            dic[aa] = set()
            dic[aa].add(bb)
        else:
            dic[aa].add(bb)

        if bb not in dic:
            dic[bb] = set()
            dic[bb].add(aa)
        else:
            dic[bb].add(aa)


    p = []
    x = []
    for _ in range(q):
        s, t = map(int,input().split())
        p.append(s)
        x.append(t)

    res = [0]*n
    for i in range(q):
        res[p[i]-1] += x[i]

    visited = set()

    dfs(1, 0, visited, res, dic)
    print(*res, sep=" ")

if __name__ == '__main__':
    main()
# Original solution
N,Q = map(int,input().split())
Edge = [[] for _ in range(N+1)]

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

PX = [list(map(int,input().split())) for _ in range(Q)]

visited = [True for _ in range(N+1)]
visited[1] = False
stack = [1]
Ans = [0]*(N+1)

for p,x in PX:
    Ans[p] += x

while len(stack) > 0:
    nextnode = stack.pop()
    for e in Edge[nextnode]:
        if visited[e]:
            visited[e] = False
            stack.append(e)
            Ans[e] += Ans[nextnode]
print(*Ans[1:],sep = " ")



# Optimized solution
N, Q = map(int,input().split())
E = [[] for _ in range(N+1)]
for _ in range(N-1):
    a,b = map(int,input().split())
    E[a].append(b)
    E[b].append(a)
PX = [list(map(int,input().split())) for _ in range(Q)]

def main():
    V = [0]*(N+1)
    for p,x in PX:
        V[p] += x
    stack = [1]
    gone = [False]*(N+1)
    gone[1] = True
    while len(stack) > 0:
        node = stack.pop(-1)
        for e in E[node]:
            if not(gone[e]):
                stack.append(e)
                V[e] += V[node]
                gone[e] = True
    print(*V[1:],sep =" ")
    return 

if __name__ == "__main__":
    main()
# Original solution
import collections


def solve(N, Q, ABs, PXs):
    # print(N, ",", Q, ",", ABs, ",", PXs)
    vertexes = {}
    values = {i: 0 for i in range(N + 1)}
    for a, b in ABs:
        vertexes.setdefault(a, []).append(b)
        vertexes.setdefault(b, []).append(a)
    for p, x in PXs:
        values[p] += x

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

    queue = collections.deque()
    queue.append((1, 0))
    while queue:
        index, parent_value = queue.popleft()
        value = parent_value + values[index]
        ans[index] = value
        for child in vertexes[index]:
            if ans[child] == -1:
                queue.append((child, value))
    return " ".join([str(a) for a in ans[1:]])


# assert (solve(4, 3, [(1, 2), (2, 3), (2, 4)], [(2, 10), (1, 100), (3, 1)]) == "100 110 111 110")
# assert (solve(6 , 2 , [(1, 2), (1, 3), (2, 4), (3, 6), (2, 5)] , [(1, 10), (1, 10)]) == "20 20 20 20 20 20")

if __name__ == "__main__":
    N, Q = tuple(map(int, input().split(" ")))
    ABs = [tuple(map(int, input().split(" "))) for _ in range(N - 1)]
    PXs = [tuple(map(int, input().split(" "))) for _ in range(Q)]
    print((solve(N, Q, ABs, PXs)))


# Optimized solution

def solve(N, Q, ABs, PXs):
    values = {i: 0 for i in range(N + 1)}
    ans = [-1 for i in range(N + 1)]
    vertexes = {}
    for a, b in ABs:
        vertexes.setdefault(a, []).append(b)
        vertexes.setdefault(b, []).append(a)

    for p, x in PXs:
        values[p] += x

    queue = []
    queue.append((1, 0))
    while queue:
        index, parent_value = queue.pop()
        value = parent_value + values[index]
        ans[index] = value
        for child in vertexes[index]:
            if ans[child] == -1:
                queue.append((child, value))
    return " ".join([str(a) for a in ans[1:]])


assert (solve(4, 3, [(1, 2), (2, 3), (2, 4)], [(2, 10), (1, 100), (3, 1)]) == "100 110 111 110")
assert (solve(6 , 2 , [(1, 2), (1, 3), (2, 4), (3, 6), (2, 5)] , [(1, 10), (1, 10)]) == "20 20 20 20 20 20")

if __name__ == "__main__":
    N, Q = tuple(map(int, input().split(" ")))
    ABs = [tuple(map(int, input().split(" "))) for _ in range(N - 1)]
    PXs = [tuple(map(int, input().split(" "))) for _ in range(Q)]
    print((solve(N, Q, ABs, PXs)))
# Original solution

def solve(N, Q, ABs, PXs):
    values = {i: 0 for i in range(N + 1)}
    ans = [-1 for i in range(N + 1)]
    vertexes = {}
    for a, b in ABs:
        vertexes.setdefault(a, []).append(b)
        vertexes.setdefault(b, []).append(a)

    for p, x in PXs:
        values[p] += x

    queue = []
    queue.append((1, 0))
    while queue:
        index, parent_value = queue.pop()
        value = parent_value + values[index]
        ans[index] = value
        for child in vertexes[index]:
            if ans[child] == -1:
                queue.append((child, value))
    return " ".join([str(a) for a in ans[1:]])


assert (solve(4, 3, [(1, 2), (2, 3), (2, 4)], [(2, 10), (1, 100), (3, 1)]) == "100 110 111 110")
assert (solve(6 , 2 , [(1, 2), (1, 3), (2, 4), (3, 6), (2, 5)] , [(1, 10), (1, 10)]) == "20 20 20 20 20 20")

if __name__ == "__main__":
    N, Q = tuple(map(int, input().split(" ")))
    ABs = [tuple(map(int, input().split(" "))) for _ in range(N - 1)]
    PXs = [tuple(map(int, input().split(" "))) for _ in range(Q)]
    print((solve(N, Q, ABs, PXs)))


# Optimized solution

def solve(N, Q, ABs, PXs):
    values = {i: 0 for i in range(N + 1)}
    ans = [-1 for i in range(N + 1)]
    vertexes = {}
    for a, b in ABs:
        vertexes.setdefault(a, []).append(b)
        vertexes.setdefault(b, []).append(a)

    for p, x in PXs:
        values[p] += x

    queue = []
    queue.append((1, 0))
    while queue:
        index, parent_value = queue.pop()
        value = parent_value + values[index]
        ans[index] = value
        for child in vertexes[index]:
            if ans[child] == -1:
                queue.append((child, value))
    return " ".join([str(a) for a in ans[1:]])


if __name__ == "__main__":
    N, Q = tuple(map(int, input().split(" ")))
    ABs = [tuple(map(int, input().split(" "))) for _ in range(N - 1)]
    PXs = [tuple(map(int, input().split(" "))) for _ in range(Q)]
    print((solve(N, Q, ABs, PXs)))
# Original solution
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def solve():
    N, Q = list(map(int, input().split()))
    adjL = [[] for _ in range(N)]
    for _ in range(N-1):
        A, B = list(map(int, input().split()))
        A, B = A-1, B-1
        adjL[A].append(B)
        adjL[B].append(A)

    anss = [0] * N
    for _ in range(Q):
        p, x = list(map(int, input().split()))
        p = p-1
        anss[p] += x

    useds = [False] * N
    def dfs(vNow, x):
        useds[vNow] = True
        anss[vNow] += x
        for v2 in adjL[vNow]:
            if not useds[v2]:
                dfs(v2, anss[vNow])

    dfs(0, 0)

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

solve()


# Optimized solution
def solve():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    N, Q = list(map(int, input().split()))
    adjL = [[] for _ in range(N)]
    for _ in range(N-1):
        A, B = list(map(int, input().split()))
        A, B = A-1, B-1
        adjL[A].append(B)
        adjL[B].append(A)

    anss = [0] * N
    for _ in range(Q):
        p, x = list(map(int, input().split()))
        p = p-1
        anss[p] += x

    useds = [False] * N
    def dfs(vNow, x):
        useds[vNow] = True
        anss[vNow] += x
        ans = anss[vNow]
        for v2 in adjL[vNow]:
            if not useds[v2]:
                dfs(v2, ans)

    dfs(0, 0)

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

solve()
# Original solution
# https://atcoder.jp/contests/abc138/tasks/abc138_d

from collections import deque

def bfs(graph, start, query, n):
    queue = deque([])
    acc = query[start] if start in query else 0
    queue.append([start, acc])
    ans = [-1] * n
    ans[start] = acc

    while queue:
        idx, acc = queue.popleft()
        for child in list(graph[idx].keys()):
            if ans[child] >= 0:
                continue
            ans[child] = acc
            if child in query:
                ans[child] += query[child]
            queue.append([child, ans[child]])
    
    print((' '.join(map(str, ans))))

n,q = list(map(int, input().split()))
tree = {}
start = 0
for i in range(n-1):
    a,b = list(map(int, input().split()))
    a -= 1
    b -= 1
    if a not in tree:
        tree[a] = {}
    tree[a][b] = 1
    if b not in tree:
        tree[b] = {}
    tree[b][a] = 1

query = {}
for _ in range(q):
    p, x = list(map(int,input().split()))
    p -= 1
    if p not in query:
        query[p] = x
    else:
        query[p] += x
bfs(tree, start, query, n)


# Optimized solution
# https://atcoder.jp/contests/abc138/tasks/abc138_d

from collections import deque

def dfs(graph, start, ans, n):
    queue = deque([])
    queue.append(start)
    visited = [False] * n
    visited[start] = True

    while queue:
        parent = queue.popleft()
        for child in list(graph[parent].keys()):
            if visited[child]:
                continue
            visited[child] = True
            ans[child] += ans[parent]
            queue.append(child)
    
    print((' '.join(map(str, ans))))

n,q = list(map(int, input().split()))
tree = {}
start = 0
for i in range(n-1):
    a,b = list(map(int, input().split()))
    a -= 1
    b -= 1
    if a not in tree:
        tree[a] = {}
    tree[a][b] = 1
    if b not in tree:
        tree[b] = {}
    tree[b][a] = 1

ans = [0]*n
for _ in range(q):
    p, x = list(map(int,input().split()))
    p -= 1
    ans[p] += x
dfs(tree, start, ans, n)
# Original solution
# Input N, Q
N, Q = [int(c) for c in input().split()]

# Input edges
edges = [[] for i in range(N)]
for i in range(N-1):
    u, v = [int(c)-1 for c in input().split()]
    edges[u].append(v)
    edges[v].append(u)

# Form tree
parent = [None for i in range(N)]
childs = [[] for i in range(N)]
def dfs(root):
    parent[root] = -1
    stack = [root]
    while stack:
        now = stack.pop()
        for nex in edges[now]:
            if parent[nex] is None:
                parent[nex] = now
                childs[now].append(nex)
                stack.append(nex)
dfs(0)

# Queries
incremented = [0 for i in range(N)]
for i in range(Q):
    v, add = [int(c) for c in input().split()]
    v -= 1
    incremented[v] += add

# Lower propagate
total = [0 for i in range(N)]
def propagate(root):
    global total
    stack = [root]
    while stack:
        now = stack.pop()
        total[now] += incremented[now]
        for child in childs[now]:
            total[child] += total[now]
            stack.append(child)
propagate(0)

# Print
print((" ".join(str(num) for num in total)))
    


# Optimized solution
def main():

    # Input N, Q
    N, Q = [int(c) for c in input().split()]

    # Input edges
    edges = [[] for i in range(N)]
    for i in range(N-1):
        u, v = [int(c)-1 for c in input().split()]
        edges[u].append(v)
        edges[v].append(u)

    # Form tree
    parent = [None for i in range(N)]
    childs = [[] for i in range(N)]
    def dfs(root):
        parent[root] = -1
        stack = [root]
        while stack:
            now = stack.pop()
            for nex in edges[now]:
                if parent[nex] is None:
                    parent[nex] = now
                    childs[now].append(nex)
                    stack.append(nex)
    dfs(0)

    # Queries
    incremented = [0 for i in range(N)]
    for i in range(Q):
        v, add = [int(c) for c in input().split()]
        v -= 1
        incremented[v] += add

    # Lower propagate
    total = [0 for i in range(N)]
    def propagate(root):
        stack = [root]
        while stack:
            now = stack.pop()
            total[now] += incremented[now]
            for child in childs[now]:
                total[child] += total[now]
                stack.append(child)
    propagate(0)

    # Print
    print((" ".join(str(num) for num in total)))

main()