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

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

adj = [[] for _ in range(N)]

for _ in range(N - 1):
    a, b = map(int, input().split())
    a, b = (a - 1, b - 1)
    adj[a].append(b)
    adj[b].append(a)
    
values = [0 for _ in range(N)]
    
for _ in range(Q):
    p, x = map(int, input().split())
    values[p - 1] += x

def dfs(node, parent):
    for child in adj[node]:
        if child == parent: continue
        values[child] += values[node]
        dfs(child, node)

dfs(0, -1)

print(*values, sep=" ")
    


# Optimized solution
#/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

def input():
    return sys.stdin.readline()

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

adj = [[] for _ in range(N)]

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

def dfs(node, parent):
    for child in adj[node]:
        if child == parent: continue
        values[child] += values[node]
        dfs(child, node)

dfs(0, -1)

print((" ".join(map(str, values))))
# Original solution
import sys
sys.setrecursionlimit(2 *(10**5) + 1)
def main():
    N, Q = list(map(int, input().split()))
    d = {}
    for _ in range(N-1):
        a, b = list(map(int, input().split()))
        if a in d:
            d[a].append(b)
        else:
            d[a] = [b]
        if b in d:
            d[b].append(a)
        else:
            d[b] = [a]
    dc = {}
    for _ in range(Q):
        p, x = list(map(int, input().split()))
        if p in dc:
            dc[p] += x
        else:
            dc[p] = x
    v = set()
    l = [0] * N
    def dfs(n, p):
        v.add(n)
        if n in dc:
            p += dc[n]
        for i in d[n]:
            if i not in v:
                dfs(i, p)
        l[n-1] = p
    dfs(1, 0)
    return ' '.join(str(i) for i in l)

print((main()))


# Optimized solution
def main():
    N, Q = list(map(int, input().split()))
    d = {}
    for _ in range(N-1):
        a, b = list(map(int, input().split()))
        if a in d:
            d[a].append(b)
        else:
            d[a] = [b]
        if b in d:
            d[b].append(a)
        else:
            d[b] = [a]
    dc = {}
    for _ in range(Q):
        p, x = list(map(int, input().split()))
        if p in dc:
            dc[p] += x
        else:
            dc[p] = x
    v = set()
    vr = set(range(1,N+1))
    l = [0] * N
    n = [(1,0)]
    c = []
    while v != vr:
        for i, j in n:
            v.add(i)
            if i in dc:
                j += dc[i]
            l[i-1] = j
            for k in d[i]:
                if k not in v:
                    c.append((k, j))
        n = c
        c = []
    return ' '.join(str(i) for i in l)

print((main()))
# Original solution
n, q = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(n-1)]
P = [list(map(int,input().split())) for i in range(q)]

ANS = [0] * (n+1)

C_plus = [0] * (n+1)
for i in range(q):
    C_plus[P[i][0]] += P[i][1]

oya = [0] * (n+1)
E = [[] for i in range(n+1)]
V = [0] * (n+1)
Q = [1]
t = 0

V[1] = 1
ANS[1] = C_plus[1]

for i in range(n-1):
    E[A[i][0]].append(A[i][1])
    E[A[i][1]].append(A[i][0])

def tansaku(x):
    for i in E[x]:
        if V[i] == 0:
            oya[i] = x
            ANS[i] = C_plus[i] + ANS[x]
            V[i] = 1
            Q.append(i)
            #print(Q)

while t < len(Q):
    tansaku(Q[t])
    t += 1

#print(ANS)

for i in range(n+1):
    ANS[i] = str(ANS[i])
print((" ".join(ANS[1:])))

# Optimized solution
n, q = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(n-1)]
P = [list(map(int,input().split())) for i in range(q)]

ANS = [0] * (n+1)

C_plus = [0] * (n+1)
for i in range(q):
    C_plus[P[i][0]] += P[i][1]

E = [[] for i in range(n+1)]
V = [0] * (n+1)
Q = [1]
t = 0

V[1] = 1
ANS[1] = C_plus[1]

for i in range(n-1):
    E[A[i][0]].append(A[i][1])
    E[A[i][1]].append(A[i][0])

def tansaku(x):
    for i in E[x]:
        if V[i] == 0:
            ANS[i] = C_plus[i] + ANS[x]
            V[i] = 1
            Q.append(i)
            #print(Q)

while t < len(Q):
    tansaku(Q[t])
    t += 1

#print(ANS)

for i in range(n+1):
    ANS[i] = str(ANS[i])
print((" ".join(ANS[1:])))
# Original solution
n, q = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(n-1)]
P = [list(map(int,input().split())) for i in range(q)]

ANS = [0] * (n+1)

C_plus = [0] * (n+1)
for i in range(q):
    C_plus[P[i][0]] += P[i][1]

E = [[] for i in range(n+1)]
V = [0] * (n+1)
Q = [1]
t = 0

V[1] = 1
ANS[1] = C_plus[1]

for i in range(n-1):
    E[A[i][0]].append(A[i][1])
    E[A[i][1]].append(A[i][0])

def tansaku(x):
    for i in E[x]:
        if V[i] == 0:
            ANS[i] = C_plus[i] + ANS[x]
            V[i] = 1
            Q.append(i)
            #print(Q)

while t < len(Q):
    tansaku(Q[t])
    t += 1

#print(ANS)

for i in range(n+1):
    ANS[i] = str(ANS[i])
print((" ".join(ANS[1:])))

# Optimized solution
n, q = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(n-1)]
P = [list(map(int,input().split())) for i in range(q)]

ANS = [0] * (n+1)

C_plus = [0] * (n+1)
for i in range(q):
    C_plus[P[i][0]] += P[i][1]

E = [[] for i in range(n+1)]
V = [0] * (n+1)
Q = [0] * (n+2)
Q[0] = 1
t = 0
r = 1

V[1] = 1
ANS[1] = C_plus[1]

for i in range(n-1):
    E[A[i][0]].append(A[i][1])
    E[A[i][1]].append(A[i][0])

def tansaku(x):
    global r
    for i in E[x]:
        if V[i] == 0:
            ANS[i] = C_plus[i] + ANS[x]
            V[i] = 1
            Q[r] = i
            r += 1
            #print(Q)

while t != r:
    tansaku(Q[t])
    t += 1

#print(ANS)

for i in range(n+1):
    ANS[i] = str(ANS[i])
print((" ".join(ANS[1:])))
# Original solution
from sys import setrecursionlimit


setrecursionlimit(2 * 10**5) #再帰の回数制限を増やす


def add_num(i, total, parent=-1):
    """隣接リストを取り出して深さ優先探索
    自分より上層の total のカウント数と部分木の頂点としてのカウント数を足す"""
    for p in adj[i]:
        if p != parent:
            ans_lst[p] = total + tmp[p]
            if adj[p] != [parent]:
                add_num(p, total + tmp[p], i)
    return
    
    
N, Q = [int(i) for i in input().split()]

adj = [[] for _ in range(N)] # 隣接リスト
tmp = [0] * N # 部分木の根としてのカウント数 
ans_lst = [0] * N # 答えのリスト

# 隣接リストの作成
for _ in range(N - 1):
    a, b = [int(i) - 1 for i in input().split()]
    adj[a].append(b)
    adj[b].append(a)

# ｔｍｐリストの作成
for _ in range(Q):
    p, x = [int(i) for i in input().split()]
    tmp[p-1] += x

ans_lst[0] = tmp[0]
total = tmp[0]
add_num(0, total)

print(*ans_lst, sep=' ')


# Optimized solution
import sys

sys.setrecursionlimit(10**6) #再帰の回数制限を増やす
input = sys.stdin.readline


def add_num(i, total, parent=-1):
    """隣接リストを取り出して深さ優先探索
    自分より上層の total のカウント数と部分木の頂点としてのカウント数を足す"""
    for p in adj[i]:
        if p != parent:
            ans_lst[p] = total + tmp[p]
            add_num(p, total + tmp[p], i)
    return
    
    
N, Q = [int(i) for i in input().split()]

adj = [[] for _ in range(N)] # 隣接リスト
tmp = [0] * N # 部分木の根としてのカウント数 
ans_lst = [0] * N # 答えのリスト

# 隣接リストの作成
for _ in range(N - 1):
    a, b = [int(i) - 1 for i in input().split()]
    adj[a].append(b)
    adj[b].append(a)

# ｔｍｐリストの作成
for _ in range(Q):
    p, x = [int(i) for i in input().split()]
    tmp[p-1] += x

ans_lst[0] = tmp[0]
total = tmp[0]
add_num(0, total)

print(*ans_lst, sep=' ')
# Original solution
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,Q = inpl()

lines = defaultdict(set)
for _ in range(N-1):
    a,b = inpl()
    a,b = a-1,b-1
    lines[a].add(b)
    lines[b].add(a)

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

visited = [False]*N
ans = [0]*N

q = queue.LifoQueue()
q.put([0,0])

while not q.empty():
    x,cnt = q.get()
    visited[x] = True
    cnt += adds[x]
    ans[x] += cnt
    for t in lines[x]:
        if not visited[t]:
            q.put([t,cnt])

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


# Optimized solution
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,Q = inpl()

lines = defaultdict(set)
for _ in range(N-1):
    a,b = inpl()
    a,b = a-1,b-1
    lines[a].add(b)

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

visited = [False]*N
ans = [0]*N

q = queue.LifoQueue()
q.put([0,0])

while not q.empty():
    x,cnt = q.get()
    cnt += adds[x]
    ans[x] += cnt
    for t in lines[x]:
        q.put([t,cnt])

print((' '.join(map(str,ans))))
# Original solution
import sys
sys.setrecursionlimit(10**7)
N,Q=list(map(int,input().split()))
ab=[[] for _ in range(N)]
for i in range(N-1):
  a,b=list(map(int,input().split()))
  ab[a-1].append(b)
  ab[b-1].append(a)

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

def dfs(p,par):
  for i in ab[p-1]:
    if i!=par:
      P[i-1]+=P[p-1]
      dfs(i,p)

dfs(1,-12345)
print((" ".join(map(str,P))))

# Optimized solution
import sys
sys.setrecursionlimit(10**7)
input=lambda :sys.stdin.readline()
N,Q=list(map(int,input().split()))
ab=[[] for _ in range(N)]
for i in range(N-1):
  a,b=list(map(int,input().split()))
  ab[a-1].append(b)
  ab[b-1].append(a)

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

def dfs(p,par):
  for i in ab[p-1]:
    if i!=par:
      P[i-1]+=P[p-1]
      dfs(i,p)

dfs(1,-12345)
print((" ".join(map(str,P))))
# Original solution
import sys
from collections import defaultdict
sys.setrecursionlimit(100000)
N, Q = map(int, input().split())

neighbor = defaultdict(list)
counter = [0] * N
pcounter = [None] * N

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

def solve():
    stack = [(0, None)]
    while stack:
        (node, parent) = stack.pop()
        pcounter[node] = counter[node]
        if parent is not None:
            pcounter[node] += pcounter[parent]
        for c in neighbor[node]:
            if pcounter[c] is None:
                stack.append((c, node))

solve()
print(*pcounter, sep=' ')


# Optimized solution
import sys
from collections import defaultdict
sys.setrecursionlimit(100000)
N, Q = map(int, input().split())

neighbor = defaultdict(list)
counter = [0] * N
pcounter = [None] * N
depth = {0: 0}

for i in range(N-1):
    a, b = map(int, input().split())
    a_deper, b_deeper = False, False
    if a in depth and b not in depth:
        depth[b] = depth[a] + 1
    if b in depth and a not in depth:
        depth[a] = depth[b] + 1
    if a in depth and b in depth:
        if depth[a] < depth[b]:
            neighbor[a-1].append(b-1)
        else:
            neighbor[b-1].append(a-1)
    else:
            neighbor[a-1].append(b-1)
            neighbor[b-1].append(a-1)

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

def solve():
    stack = [(0, None)]
    while stack:
        (node, parent) = stack.pop()
        pcounter[node] = counter[node]
        if parent is not None:
            pcounter[node] += pcounter[parent]
        for c in neighbor[node]:
            if pcounter[c] is None:
                stack.append((c, node))

solve()
print(*pcounter, sep=' ')
# Original solution
n,q=list(map(int,input().split()))
lst=[[] for i in range(n)]
ans=[0]*n

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

for i in range(q):
    s,t=list(map(int,input().split()))
    ans[s-1]+=t

Q=[0]

flag=[True]+[False]*(n-1)


while Q:
  v=Q.pop(0)
  flag[v]=True
  for i in lst[v]:
    if flag[i]:
      continue
    flag[i]=True
    ans[i]+=ans[v]
    Q.append(i)


print((' '.join([str(i) for i in ans])))


# Optimized solution
n,q=list(map(int,input().split()))
lst=[[] for i in range(n)]
ans=[0]*n

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

for i in range(q):
    s,t=list(map(int,input().split()))
    ans[s-1]+=t

Q=[0]

flag=[True]+[False]*(n-1)


while Q:
  v=Q.pop()
  flag[v]=True
  for i in lst[v]:
    if flag[i]:
      continue
    flag[i]=True
    ans[i]+=ans[v]
    Q.append(i)


print((' '.join([str(i) for i in ans])))
# Original solution
import sys

sys.setrecursionlimit(10**6)

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

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

plus = [0] * (n + 1)

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

def calc(num, path, plus, parent):
  for i in path[num]:
    if i == parent:
      continue

    plus[i] += plus[num]
    calc(i, path, plus, num)

calc(1, path, plus, 0)

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


# Optimized solution
import sys

sys.setrecursionlimit(10**6)

n, q = list(map(int, sys.stdin.readline().strip().split()))

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

plus = [0] * (n + 1)

for _ in range(q):
  p, x = list(map(int, sys.stdin.readline().strip().split()))
  plus[p] += x

def calc(num, path, plus, parent):
  for i in path[num]:
    if i == parent:
      continue

    plus[i] += plus[num]
    calc(i, path, plus, num)

calc(1, path, plus, 0)

print((" ".join([str(i) for i in plus[1:]])))
# Original solution
from collections import defaultdict
import queue

N, Q = list(map(int, input().split()))
adjacent = defaultdict(list)
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    adjacent[a].append(b)
    adjacent[b].append(a)
ans = [0] * N
for i in range(Q):
    p, x = list(map(int, input().split()))
    p -= 1
    ans[p] += x

q = queue.Queue()
q.put((0, -1))
while not q.empty():
    u, p = q.get()
    for v in adjacent[u]:
        if v == p:
            continue
        ans[v] += ans[u]
        q.put((v, u))
print((' '.join([str(ans[i]) for i in range(N)])))


# Optimized solution
from collections import defaultdict, deque

N, Q = list(map(int, input().split()))
adjacent = defaultdict(list)
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    adjacent[a].append(b)
    adjacent[b].append(a)
ans = [0] * N
for i in range(Q):
    p, x = list(map(int, input().split()))
    p -= 1
    ans[p] += x

q = deque([(0, -1)])
while len(q) > 0:
    u, p = q.pop()
    for v in adjacent[u]:
        if v == p:
            continue
        ans[v] += ans[u]
        q.appendleft((v, u))
print((' '.join([str(ans[i]) for i in range(N)])))
# Original solution
import sys
sys.setrecursionlimit(250000)
from collections import defaultdict

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

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

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

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


def dfs(v, p, cnt):
    cnt += val[v]
    ans[v] = cnt
    for next_v in nl[v]:
        if next_v != p:
            dfs(next_v, v, cnt)


dfs(1, -1, 0)
c = [0 for _ in range(N + 1)]
print((' '.join([str(a) for a in ans[1:]])))


# Optimized solution
from collections import defaultdict

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

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

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

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

stack = list()
stack.append((0, -1, 0))
while len(stack) > 0:
    v, p, cnt = stack.pop()
    cnt += val[v]
    ans[v] = cnt
    for next_v in nl[v]:
        if next_v != p:
            stack.append((next_v, v, cnt))

print((' '.join([str(a) for a in ans[1:]])))
# Original solution
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

N, Q = list(map(int, input().split()))
info = [[] for _ in range(N)]
ans = [0 for _ in range(N)]

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


def checker(n):
    for i in info[n]:
        if n in info[i]:
            del info[i][info[i].index(n)]
        checker(i)


def plus(n, val):
    ans[n] += val
    for i in info[n]:
        plus(i, val + Query[i])


checker(0)
Query = [0 for _ in range(N)]
for _ in range(Q):
    p, x = list(map(int, input().split()))
    Query[p - 1] += x
plus(0, Query[0])
ans = list(map(str, ans))
print((" ".join(ans)))


# Optimized solution
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

N, Q = list(map(int, input().split()))
info = [[] for _ in range(N)]
ans = [0 for _ in range(N)]

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


def checker(n, info2):
    for i in info[n]:
        if n in info2[i]:
            continue
        else:
            info2[n].append(i)
            checker(i, info2)


def plus(n, val):
    ans[n] += val
    for i in info2[n]:
        plus(i, val + Query[i])


info2 = [[] for _ in range(N)]
checker(0, info2)
Query = [0 for _ in range(N)]
for _ in range(Q):
    p, x = list(map(int, input().split()))
    Query[p - 1] += x
plus(0, Query[0])
ans = list(map(str, ans))
print((" ".join(ans)))
# Original solution
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

N, Q = list(map(int, input().split()))
info = [[] for _ in range(N)]
ans = [0 for _ in range(N)]
check = [True for _ in range(N)]

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


def plus(n, val):
    ans[n] += val
    check[n] = False
    for i in info[n]:
        if check[i]:
            plus(i, val + Query[i])


Query = [0 for _ in range(N)]
for _ in range(Q):
    p, x = list(map(int, input().split()))
    Query[p - 1] += x
plus(0, Query[0])
ans = list(map(str, ans))
print((" ".join(ans)))


# Optimized solution
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

N, Q = list(map(int, input().split()))
info = [[] for _ in range(N)]
ans = [0 for _ in range(N)]
check = [1 for _ in range(N)]

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


def plus(n, val):
    ans[n] += val
    check[n] = 0
    for i in info[n]:
        if check[i]:
            plus(i, val + Query[i])


Query = [0 for _ in range(N)]
for _ in range(Q):
    p, x = list(map(int, input().split()))
    Query[p - 1] += x
plus(0, Query[0])
ans = list(map(str, ans))
print((" ".join(ans)))
# Original solution
N,Q=list(map(int,input().split()))
ans=[0]*N
ki=[[] for _ in range(N)]
for i in range(N-1):
 a,b=list(map(int,input().split()))
 ki[a-1].append(b-1)
 ki[b-1].append(a-1)
for i in range(Q):
 p,q=list(map(int,input().split()))
 ans[p-1]+=q
# dfs
stack = [0]
visited = ["False"] * N
while stack:
 ne = stack.pop()
 if visited[ne] == "False":
  visited[ne] = "True"
  for j in ki[ne]:
   if visited[j] == "False":
    ans[j]+=ans[ne]
    stack.append(j)
L=[str(a) for a in ans]
L=' '.join(L)
print(L)

# Optimized solution
import sys
input = sys.stdin.readline
N,Q=list(map(int,input().split()))
ans=[0]*N
ki=[[] for _ in range(N)]
for i in range(N-1):
 a,b=list(map(int,input().split()))
 ki[a-1].append(b-1)
 ki[b-1].append(a-1)
for i in range(Q):
 p,q=list(map(int,input().split()))
 ans[p-1]+=q
# dfs
stack = [0]
visited = ["False"] * N
while stack:
 ne = stack.pop()
 if visited[ne] == "False":
  visited[ne] = "True"
  for j in ki[ne]:
   if visited[j] == "False":
    ans[j]+=ans[ne]
    stack.append(j)
L=[str(a) for a in ans]
L=' '.join(L)
print(L)
# Original solution
#!/usr/bin/env python
from collections import deque

def main():
    n, q = list(map(int, input().split()))
    link = [[] for _ in range(n+1)]
    for _ in range(n-1):
        a, b = list(map(int, input().split()))
        link[a].append(b)
        link[b].append(a)
    manip = [list(map(int, input().split())) for _ in range(q)]

    child = [[] for _ in range(n+1)]
    parent = [0 for _ in range(n+1)]
    unchecked = [True for _ in range(n+1)]
    unchecked[1] = False
    que = deque([1])
    while que:
        p = que.popleft()
        for l in link[p]:
            if unchecked[l]:
                unchecked[l] = False
                child[p].append(l)
                parent[l] = p
                que.append(l)

    cnt = [0 for _ in range(n+1)]
    for m in manip:
        node, x = m
        cnt[node] += x

    que = deque([1])
    while que:
        node = que.pop()
        cnt[node] += cnt[parent[node]]
        que.extend(child[node])

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

if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python
from collections import deque

def main():
    n, q = list(map(int, input().split()))
    link = [[] for _ in range(n+1)]
    for _ in range(n-1):
        a, b = list(map(int, input().split()))
        link[a].append(b)
        link[b].append(a)
    manip = [list(map(int, input().split())) for _ in range(q)]

    cnt = [0 for _ in range(n+1)]
    for m in manip:
        node, x = m
        cnt[node] += x

    parent = [0 for _ in range(n+1)]
    unchecked = [True for _ in range(n+1)]
    unchecked[1] = False
    que = deque([1])
    while que:
        node = que.pop()
        for l in link[node]:
            if unchecked[l]:
                unchecked[l] = False
                cnt[l] += cnt[node]
                que.append(l)

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

if __name__ == '__main__':
    main()