CodeEff/ECCO huggingface dataset:
# Original 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)


# Optimized solution
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

# 遅延評価で加えてあげるだけ

N,Q = list(map(int,readline().split()))
lines = readlines()
AB = (tuple(int(x) for x in line.split()) for line in lines[:N-1])
PX = (tuple(int(x) for x in line.split()) for line in lines[-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

par = [None] * (N+1)
q = [1]
while q:
    x = q.pop()
    for y in graph[x]:
        if y == par[x]:
            continue
        value[y] += value[x]
        q.append(y)
        par[y] = x

answer = ' '.join(map(str,value[1:]))
print(answer)
# Original solution
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

# 遅延評価で加えてあげるだけ

N,Q = list(map(int,readline().split()))
AB = (tuple(int(x) for x in readline().split()) for _ in range(N-1))
PX = (tuple(int(x) for x in readline().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

par = [None] * (N+1)
q = [1]
while q:
    x = q.pop()
    for y in graph[x]:
        if y == par[x]:
            continue
        value[y] += value[x]
        q.append(y)
        par[y] = x

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


# Optimized solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,Q = list(map(int,readline().split()))
ABPX = list(map(int,read().split()))
AB = iter(ABPX[:N+N-2])
PX = iter(ABPX[N+N-2:])

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

val = [0] * (N+1)
for p,x in zip(PX,PX):
    val[p] += x

stack = [1]
parent = [0] * (N+1)
while stack:
    x = stack.pop()
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)
        val[y] += val[x]

print((' '.join(map(str,val[1:]))))
# Original solution
def main():
    N, Q = list(map(int, input().split()))

    graph = dict()
    for i in range(N-1):
        a, b = list(map(int, input().split()))
        if a not in graph: graph[a] = [b]
        else: graph[a].append(b)
        # if b not in graph: graph[b] = [a]
        # else: graph[b].append(a)

    ops = dict()
    for i in range(Q):
        p, x = list(map(int, input().split()))
        if p not in ops: ops[p] = x
        else: ops[p] += x

    # print(graph)
    # print(ops)
    vals = [0 for _ in range(N)]
    v = 0
    if 1 in ops: v = ops[1]
    cur = [[1, v]]

    visited = set([1])
    while cur:
        temp = []
        for a, v in cur:
            vals[a-1] += v
            if a in graph:
                for b in graph[a]:
                    if b not in visited:
                        if b in ops:
                            temp.append([b, v+ops[b]])
                        else:
                            temp.append([b, v])
                        visited.add(b)
        cur = temp

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

if __name__ == '__main__':
    main()

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

    graph = dict()
    for i in range(N-1):
        a, b = list(map(int, input().split()))
        if a not in graph: graph[a] = [b]
        else: graph[a].append(b)
        # if b not in graph: graph[b] = [a]
        # else: graph[b].append(a)

    ops = dict()
    for i in range(Q):
        p, x = list(map(int, input().split()))
        if p not in ops: ops[p] = x
        else: ops[p] += x

    # print(graph)
    # print(ops)
    vals = [0 for _ in range(N)]
    v = 0
    if 1 in ops: v = ops[1]
    cur = [[1, v]]

    while cur:
        temp = []
        for a, v in cur:
            vals[a-1] += v
            if a in graph:
                for b in graph[a]:
                    if b in ops:
                        temp.append([b, v+ops[b]])
                    else:
                        temp.append([b, v])
        cur = temp

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

if __name__ == '__main__':
    main()
# Original solution
import sys
import heapq
import bisect

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def main():
    N,Q = LI()
    Child = [[] for _ in range(N)]
    tree = [False]*N
    tree[0] = True
    cur_tree = []
    for _ in range(N-1):
        a,b = LI()
        cur_tree.append([a-1,b-1])

    counter = [0] * N
    for _ in range(Q):
        p,x = LI()
        counter[p-1] += x

    while cur_tree:
        nxt_tree = []
        for a,b in cur_tree:
            if tree[a]:
                Child[a].append(b)
                counter[b] += counter[a]
                tree[b] = True
            elif tree[b]:
                Child[b].append(a)
                counter[a] += counter[b]
                tree[a] = True
            else:
                nxt_tree.append([a,b])
        cur_tree = [x for x in nxt_tree]

    r = [counter[i] for i in range(N)]

    return(" ".join(map(str,r)))

if __name__ == "__main__":
    print((main()))


# Optimized solution
import sys
import heapq
import bisect

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def main():
    N,Q = LI()
    node=[[] for _ in range(N)]
    flag = [True for _ in range(N)]
    for _ in range(N-1):
        a,b = LI()
        node[a-1].append(b-1)
        node[b-1].append(a-1)

    counter = [0] * N
    for _ in range(Q):
        p,x = LI()
        counter[p-1] += x

    cur = [[0,0]]
    while cur:
        nxt = []
        for a,c in cur:
            flag[a]=False
            counter[a]+=c
            for b in node[a]:
                if flag[b]:
                    nxt.append([b,counter[a]])
        cur = [x for x in nxt]

    r = [counter[i] for i in range(N)]

    return(" ".join(map(str,r)))

if __name__ == "__main__":
    print((main()))
# Original solution
import sys
import heapq
import bisect

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def main():
    N,Q = LI()
    node=[[] for _ in range(N)]
    flag = [True for _ in range(N)]
    for _ in range(N-1):
        a,b = LI()
        node[a-1].append(b-1)
        node[b-1].append(a-1)

    counter = [0] * N
    for _ in range(Q):
        p,x = LI()
        counter[p-1] += x

    cur = [[0,0]]
    while cur:
        nxt = []
        for a,c in cur:
            flag[a]=False
            counter[a]+=c
            for b in node[a]:
                if flag[b]:
                    nxt.append([b,counter[a]])
        cur = [x for x in nxt]

    r = [counter[i] for i in range(N)]

    return(" ".join(map(str,r)))

if __name__ == "__main__":
    print((main()))


# Optimized solution
import sys

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])

def main():
    N,Q = LI()
    node=[[] for _ in range(N)]
    flag = [True for _ in range(N)]
    for _ in range(N-1):
        a,b = LI()
        node[a-1].append(b-1)
        node[b-1].append(a-1)

    counter = [0] * N
    for _ in range(Q):
        p,x = LI()
        counter[p-1] += x

    que = [[0,0]]
    while que:
        a,c = que.pop()
        flag[a]=False
        counter[a]+=c
        for b in node[a]:
            if flag[b]:
                que.append([b,counter[a]])

    r = [counter[i] for i in range(N)]

    return(" ".join(map(str,r)))

if __name__ == "__main__":
    print((main()))
# Original solution
import sys
sys.setrecursionlimit(200005)

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, q = na()
g = [[] for _ in range(n)]
for i in range(n-1):
    a, b = na()
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

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

ans = [0] * (n+1)

def dfs(cur, pre):
    global ps, ans, g
    ans[cur] = ans[pre] + ps[cur]
    for e in g[cur]:
        if e != pre:
            dfs(e, cur)

dfs(0, -1)

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


# Optimized solution
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, q = na()
g = [[] for _ in range(n)]
for i in range(n-1):
    a, b = na()
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

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

stack = [0] * (n+1)
inds = [0] * (n+1)

sp = 0
stack[sp] = 0
sp += 1

while sp > 0:
    cur = stack[sp-1]
    if inds[sp-1] == len(g[cur]):
        sp -= 1
        continue
    if inds[sp-1] == 0 and sp > 1:
        ps[cur] += ps[stack[sp-2]]
    if sp == 1 or stack[sp-2] != g[cur][inds[sp-1]]:
        stack[sp] = g[cur][inds[sp-1]]
        inds[sp] = 0
        inds[sp-1] += 1
        sp += 1
        continue
    inds[sp - 1] += 1

print((" ".join(map(str, ps))))
# Original solution
from collections import defaultdict, deque

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

connect_dic = defaultdict(list)

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

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

used = set()
dq = deque([1])
used.add(1)
ans = [0] * (N + 1)

while dq:
    node = dq.popleft()
    can = connect_dic[node]

    used.add(node)
    ans[node] += query_weight[node]

    for c in can:
        if c not in used:
            ans[c] += ans[node]
            dq.append(c)


ans = [str(w) for w in ans[1:]]
print((' '.join(ans)))


# Optimized solution
from collections import deque

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

connect_lst = [[] for _ in range(N + 1)]

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

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

used = set()
dq = deque([1])
used.add(1)
ans = [0] * (N + 1)

while dq:
    node = dq.popleft()
    can = connect_lst[node]

    used.add(node)
    ans[node] += query_weight[node]

    for c in can:
        if c not in used:
            ans[c] += ans[node]
            dq.append(c)


ans = [str(w) for w in ans[1:]]
print((' '.join(ans)))
# Original solution
from collections import defaultdict
import sys

sys.setrecursionlimit(300000)

N, Q = list(map(int, input().split()))
tree = defaultdict(list)
counter = [0] * N
for i in range(N-1):
    a, b = list(map(int, input().split()))
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

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

visited = [False] * N


def dfs(parent):
    visited[parent] = True
    for child in tree[parent]:
        if not visited[child]:
            counter[child] += counter[parent]
            dfs(child)


dfs(0)
print((' '.join(map(str, counter))))


# Optimized solution
from collections import defaultdict, deque

N, Q = list(map(int, input().split()))
tree = defaultdict(list)
counter = [0] * N
for i in range(N-1):
    a, b = list(map(int, input().split()))
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

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

visited = [False] * N

queue = deque()
queue.append(0)
while queue:
    parent = queue.popleft()
    visited[parent] = True
    for child in tree[parent]:
        if not visited[child]:
            counter[child] += counter[parent]
            queue.append(child)

print((' '.join(map(str, counter))))
# Original solution
import queue
import sys
sys.setrecursionlimit(5*10**5)

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

cnt=[0]*(N+1)
for el in px:
    cnt[el[0]]+=el[1]
#print(cnt)


lst=[[] for _ in range(N+1)]
for el in ab:
    lst[el[0]].append(el[1])
    lst[el[1]].append(el[0])
#print(lst)

seen = [False] * (N + 1)
def dfs(n):
    seen[n] = True
    for child in lst[n]:
        if seen[child] == False:
            cnt[child]+=cnt[n]
            dfs(child)

dfs(1)
#print(cnt)
print((' '.join(list(map(str, cnt[1:])))))

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

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

cnt=[0]*(N+1)
for el in px:
    cnt[el[0]] += el[1]
#print(cnt)


lst=[[] for _ in range(N+1)]
for el in ab:
    lst[el[0]].append(el[1])
    lst[el[1]].append(el[0])
#print(lst)

seen = [False] * (N + 1)
def dfs(n):
    seen[n] = True
    for child in lst[n]:
        if seen[child] == False:
            cnt[child]+=cnt[n]
            dfs(child)

dfs(1)
#print(cnt)
print((' '.join(list(map(str, cnt[1:])))))
# Original solution
import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline

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

cnt=[0]*(N+1)
for el in px:
    cnt[el[0]] += el[1]
#print(cnt)


lst=[[] for _ in range(N+1)]
for el in ab:
    lst[el[0]].append(el[1])
    lst[el[1]].append(el[0])
#print(lst)

seen = [False] * (N + 1)
def dfs(n):
    seen[n] = True
    for child in lst[n]:
        if seen[child] == False:
            cnt[child]+=cnt[n]
            dfs(child)

dfs(1)
#print(cnt)
print((' '.join(list(map(str, cnt[1:])))))

# Optimized solution
import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
 
N, Q = list(map(int, input().split()))
ab=[]
for _ in range(N-1):
    ab.append(tuple(map(int, input().split())))
px=[]
for _ in range(Q):
    px.append(tuple(map(int, input().split())))
 
cnt=[0]*(N+1)
for el in px:
    cnt[el[0]] += el[1]
#print(cnt)
 
 
lst=[[] for _ in range(N+1)]
for el in ab:
    lst[el[0]].append(el[1])
    lst[el[1]].append(el[0])
#print(lst)
 
seen = set()
def dfs(n):
    seen.add(n)
    for child in lst[n]:
        if child not in seen:
            cnt[child]+=cnt[n]
            dfs(child)
 
dfs(1)
#print(cnt)
print((' '.join(list(map(str, cnt[1:])))))
# Original solution
import collections

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

tree = [[] for _ in range(n)]
edge = collections.deque(edge)
flag = [False] * n
flag[0] = True
while len(edge) != 0:
    a, b = edge.popleft()
    if flag[a - 1]:
        tree[a - 1].append(b - 1)
        flag[b - 1] = True
    elif flag[b - 1]:
        tree[b - 1].append(a - 1)
        flag[a - 1] = True
    else:
        edge.append((a, b))

que = collections.deque([0])
while len(que) != 0:
    i = que.popleft()
    for j in tree[i]:
        counter[j] += counter[i]
        que.append(j)

print((' '.join([str(c) for c in counter])))

# Optimized solution
import collections

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

tree = [[] for _ in range(n)]
edge = collections.deque(edge)
while len(edge) != 0:
    a, b = edge.popleft()
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)

que = collections.deque([0])
flag = [False] * n
while len(que) != 0:
    i = que.popleft()
    flag[i] = True
    for j in tree[i]:
        if flag[j]: continue
        counter[j] += counter[i]
        que.append(j)

print((' '.join([str(c) for c in counter])))
# Original solution
import sys
sys.setrecursionlimit(10 ** 7)


def dfs(tree, count, p):
    # print(p, tree[p])
    for i in tree[p]:
        count[i] += count[p]
        dfs(tree, count, i)


def solve(tree, count):
    from collections import deque
    stk = deque([1])

    while stk:
        p = stk.pop()
        for i in tree[p]:
            count[i] += count[p]
            stk.append(i)


def remove_parents(tree, p):
    for i in tree[p]:
        tree[i].remove(p)
        remove_parents(tree, i)


def main():
    N, Q = list(map(int, input().split()))
    tree = {i+1: set() for i in range(N)}
    count = {i+1: 0 for i in range(N)}

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

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

    # print(count)

    # visited = {k+1: False for k in range(N)}
    # visited[1] = True

    remove_parents(tree, 1)
    # print(tree)
    # dfs(tree, count, 1)
    solve(tree, count)

    ans = [str(count[k]) for k in sorted(count.keys())]
    print((" ".join(ans)))


if __name__ == '__main__':
    main()

# Optimized solution
from collections import defaultdict, deque


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

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

    # bfs
    q = deque([1])
    visited = {1}

    while q:
        i = q.popleft()

        for j in tree[i]:
            if j not in visited:
                q.append(j)
                counter[j] += counter[i]
                visited.add(j)

    counts = [counter[i] for i in range(1, N+1)]
    ans = " ".join(map(str, counts))
    print(ans)



if __name__ == '__main__':
    main()
# Original solution
import queue

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

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

c = [0]*n

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

ans = [0]*n
visited = [0]*n

que = queue.Queue()

que.put(0)
visited[0]=1
ans[0]+=c[0]

while not que.empty():
    x = que.get()
    for y in d[x]:
        if visited[y]==1:
            continue
        else:
            ans[y]+=ans[x]+c[y]
            visited[y]=1
            que.put(y)



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


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

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

c = [0]*n

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

ans = [0]*n
visited = [0]*n

que = []

que.append(0)
visited[0]=1
ans[0]+=c[0]

while que:
    x = que.pop()
    for y in d[x]:
        if visited[y]==1:
            continue
        else:
            ans[y]+=ans[x]+c[y]
            visited[y]=1
            que.append(y)



print((' '.join(map(str,ans))))
# Original solution
import sys
sys.setrecursionlimit(20000000)
N, Q = [int(i) for i in input().split()]
tree = {i:[] for i in range(1,N+1)}
cost_ls = {i:0 for i in range(1,N+1)}
for _ in range(N-1):
    a, b = list(map(int, input().split()))
    tree[a].append(b)
    tree[b].append(a)

def plus(node, _from):
    #cost_ls[node] += num
    for child in tree[node]:
        if child == _from:
            continue
        cost_ls[child] += cost_ls[node]
        plus(child, node)

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

plus(1, 0)

print((' '.join(str(cost_ls[i]) for i in range(1,N+1))))

# Optimized solution
import sys
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
N, Q = [int(i) for i in input().split()]
tree = {i:[] for i in range(1,N+1)}
cost_ls = {i:0 for i in range(1,N+1)}
for _ in range(N-1):
    a, b = list(map(int, input().split()))
    tree[a].append(b)
    tree[b].append(a)

def plus(node, _from):
    #cost_ls[node] += num
    for child in tree[node]:
        if child == _from:
            continue
        cost_ls[child] += cost_ls[node]
        plus(child, node)

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

plus(1, 0)

print((' '.join(str(cost_ls[i]) for i in range(1,N+1))))
# Original solution
n, q = list(map(int, input().split()))
tl = [list() for _ in range(n)]
ab = []
ans = [0] * n

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

ab.sort(reverse=True)

for a, b in ab:
    a -= 1
    b -= 1
    tl[a].append(b)
    tl[a].extend(tl[b])

for i in range(q):
    p, x = list(map(int, input().split()))
    ans[p-1] += x
    for num in tl[p-1]:
        ans[num] += x

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

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

for i in range(n-1):
    ab[i] = tuple(map(int, input().split()))

ab.sort(reverse=True)

for a, b in ab:
    a -= 1
    b -= 1
    tl[a].append(b)
    tl[a].extend(tl[b])

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

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