CodeEff/ECCO huggingface dataset:
# Original solution
from collections import deque


def main():
  n,q=map(int,input().split())
  node=[[]*n for i in range(n)]
  for i in range(n-1):
    a,b=map(lambda x:int(x)-1,input().split())
    node[b].append(a)
    node[a].append(b)
  
  ans=[0]*n
  for i in range(q):
    p,x=map(int,input().split())
    p-=1
    ans[p]+=x

  root=[0]*n
  edge=[[]*n for i in range(n)]
  root[0]=0
  q=deque([0])
  visited=[False]*n
  visited[0]=True
  
  while q:
    r=q.popleft()
    for e in node[r]:
      if not visited[e]:
        visited[e]=True
        q.append(e)
        root[e]=r
        edge[r].append(e)
  
  
  p=[0]*n
  q=deque(edge[0])
  visited=[False]*n
  while q:
    e=q.popleft()
    p[e]=p[root[e]]+1
    for e2 in edge[e]:
      if not visited[e2]:
        visited[e2]=True
        q.append(e2)
  
  p=sorted(enumerate(p), key=lambda x:x[1])
  for i in range(1,n):
    e=p[i][0]
    r=root[e]
    ans[e]+=ans[r]
    
  print(*ans,sep=' ')


if __name__=='__main__':
  main()


# Optimized solution
import sys
sys.setrecursionlimit(2*10**5+5)


def dfs(_v, _u):
  for u in v[_v]:
    if u==_u: continue;
    ans[u]+=ans[_v]
    dfs(u, _v)
        
  
def main():
  for i in range(n-1):
    a,b=map(lambda x:int(x)-1, input().split())
    v[a].append(b)
    v[b].append(a)
  
  for i in range(q):
    p,x=map(lambda x:int(x)-1, input().split())
    ans[p]+=x+1
  
  dfs(0,-1)
  
  print(*ans, sep=' ')
  
if __name__=='__main__':
  n,q=map(int,input().split())
  ans=[0]*n
  v=[[]*n for i in range(n)]
  main()
# Original solution
import queue

N,Q = list(map(int,input().split()))
Ki_p = [0 for i in range(N+1)]
Ki_c = [[] for i in range(N+1)]
Ki_co = [0 for i in range(N+1)]
 
for i in range(N-1):
    a,b = list(map(int,input().split()))
    Ki_p[b] = a
    Ki_c[a] += [b]
 
for i in range(Q):
    p,x = list(map(int,input().split()))
    Ki_co[p] += x
 
ans = [0 for i in range(N+1)]
q = queue.Queue()
q.put(1)
while not q.empty():
    vi = q.get()
    ans[vi] = Ki_co[vi] + ans[Ki_p[vi]]
    for a in Ki_c[vi]:
        q.put(a)
 
print((' '.join(map(str,ans[1:N+1]))))

# Optimized solution
N,Q = list(map(int,input().split()))
Ki_p = [0 for i in range(N+1)]
Ki_c = [[] for i in range(N+1)]
Ki_co = [0 for i in range(N+1)]
 
for i in range(N-1):
    a,b = list(map(int,input().split()))
    Ki_p[b] = a
    Ki_c[a] += [b]
 
for i in range(Q):
    p,x = list(map(int,input().split()))
    Ki_co[p] += x
 
ans = [0 for i in range(N+1)]
q = {1}
for i in range(N):
    vi = q.pop()
    ans[vi] = Ki_co[vi] + ans[Ki_p[vi]]
    q |= set(Ki_c[vi])
    
print((' '.join(map(str,ans[1:N+1]))))
# Original solution
import sys
sys.setrecursionlimit(5 * 10**5)

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

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

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

ans = [0] * N

def setAnswer(parent, number, value):
    ans[number] = value

    for i in range(N):
        if i != parent and M[number][i] == 1:
            setAnswer(number, i, value + X[i])

setAnswer(0, 0, X[0])

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


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

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

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

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

ans = [0] * N

def setAnswer(parent, number, value):
    ans[number] = value

    for i in M[number]:
        if i != parent:
            setAnswer(number, i, value + X[i])

setAnswer(0, 0, X[0])

print((' '.join(map(str, ans))))
# Original solution
import sys
sys.setrecursionlimit(5 * 10**5)
 
N, Q = list(map(int, input().split()))
 
M = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = list(map(int, input().split()))
    M[a-1].append(b-1)
    M[b-1].append(a-1)
 
ans = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    ans[p-1] += x
 
def setAnswer(parent, number):
    ans[number] += ans[parent]
 
    for i in M[number]:
        if i != parent:
            setAnswer(number, i)

ans.append(0)
setAnswer(N, 0)
ans.pop(N)
 
print((' '.join(map(str, ans))))


# Optimized solution
import sys
sys.setrecursionlimit(5 * 10**5)
input=sys.stdin.readline
 
N, Q = list(map(int, input().split()))
 
M = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = list(map(int, input().split()))
    M[a-1].append(b-1)
    M[b-1].append(a-1)
 
ans = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    ans[p-1] += x
 
def setAnswer(parent, number):
    ans[number] += ans[parent]
 
    for i in M[number]:
        if i != parent:
            setAnswer(number, i)

ans.append(0)
setAnswer(N, 0)
ans.pop(N)
 
print((' '.join(map(str, ans))))
# Original solution
import sys
sys.setrecursionlimit(5 * 10**5)
input=sys.stdin.readline
 
N, Q = list(map(int, input().split()))
 
M = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = list(map(int, input().split()))
    M[a-1].append(b-1)
    M[b-1].append(a-1)
 
X = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    X[p-1] += x
 
ans = [0] * N
 
def setAnswer(parent, number, value):
    ans[number] = value
 
    for i in M[number]:
        if i != parent:
            setAnswer(number, i, value + X[i])
 
setAnswer(0, 0, X[0])
 
print((' '.join(map(str, ans))))

# Optimized solution
import sys
sys.setrecursionlimit(5 * 10**5)
input=sys.stdin.readline
 
N, Q = list(map(int, input().split()))
 
M = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = list(map(int, input().split()))
    M[a-1].append(b-1)
    M[b-1].append(a-1)
 
ans = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    ans[p-1] += x
 
def setAnswer(parent, number):
    ans[number] += ans[parent]
 
    for i in M[number]:
        if i != parent:
            setAnswer(number, i)
 
for i in M[0]:
    setAnswer(0, i)
 
print((' '.join(map(str, ans))))
# Original solution
import sys
from collections import deque

sys.setrecursionlimit(5 * 10**5)
input=sys.stdin.readline

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

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

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

Q = deque([0])

while Q:
    current = Q.pop()

    for i in M[current]:
        ans[i] += ans[current]
        M[i].remove(current)
        Q.append(i)

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


# Optimized solution
import sys

sys.setrecursionlimit(5 * 10**5)
input=sys.stdin.readline

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

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

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

Q = [0]

while Q:
    current = Q.pop()

    for i in M[current]:
        ans[i] += ans[current]
        M[i].remove(current)
        Q.append(i)

print((' '.join(map(str, ans))))
# 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

def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)

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


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

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)]
 
g = [[] for _ in range(N+1)]
for a,b in AB:
    g[a].append(b)
    g[b].append(a)
 
cnt = [0] * (N+1)
for p,x in PX:
    cnt[p] += x

def dfs(v, p, add):
    cnt[v] += add
    for nv in g[v]:
        if nv == p:
            continue
        dfs(nv, v, cnt[v])

dfs(1, 0, 0)

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

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)]
 
g = [[] for _ in range(N+1)]
for a,b in AB:
    g[a].append(b)
    g[b].append(a)
 
cnt = [0] * (N+1)
for p,x in PX:
    cnt[p] += x

def dfs(v, p, add):
    cnt[v] += add
    for nv in g[v]:
        if nv == p:
            continue
        dfs(nv, v, cnt[v])

dfs(1, 0, 0)

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

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

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

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

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

def dfs(v, p, add):
    cnt[v] += add
    for nv in g[v]:
        if nv == p:
            continue
        dfs(nv, v, cnt[v])

dfs(1, 0, 0)

print((' '.join(map(str, cnt[1:]))))
# Original solution
import sys
sys.setrecursionlimit(10**6)

N, Q = list(map(int, input().split()))
G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = list(map(int, input().split()))
    G[a-1].append(b-1)
    G[b-1].append(a-1)
P = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    P[p-1] += x
ans = [-1] * N
#print(G)
#print(P)
def dfs(v, p):
    ans[v] = P[v] + p
    for vi in G[v]:
        if ans[vi] != -1:
            continue
        dfs(vi, ans[v])

dfs(0, 0)

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


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

N, Q = list(map(int, input().split()))
G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = list(map(int, input().split()))
    G[a-1].append(b-1)
    G[b-1].append(a-1)
P = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    P[p-1] += x
ans = [-1] * N
#print(G)
#print(P)

def dfs(v, p):
    ans[v] = P[v] + p
    for vi in G[v]:
        if ans[vi] != -1:
            continue
        dfs(vi, ans[v])
dfs(0, 0)

print((' '.join(map(str, ans))))
# Original solution
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(eval(input()))

def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print((k.join(list(map(str, lst)))))
INF = float('inf')
from collections import deque
def solve():
    n, q = MI()
    e = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = MI1()
        e[a].append(b)
        e[b].append(a)

    point = [0] * n
    for _ in range(q):
        p, x = MI()
        p -= 1
        point[p] += x

    d = deque([(0, point[0])])
    used = [0] * n
    used[0] = 1

    l = 1
    while l > 0:
        v, p = d.popleft()
        l -= 1
        for nv in e[v]:
            if used[nv]: continue
            used[nv] = 1
            point[nv] += p
            d.append((nv, point[nv]))
            l += 1

    printlist(point, " ")

if __name__ == '__main__':
    solve()


# Optimized solution
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(eval(input()))

def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print((k.join(list(map(str, lst)))))
INF = float('inf')
from collections import deque
def solve():
    n, q = MI()
    e = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = MI1()
        e[a].append(b)
        e[b].append(a)

    point = [0] * n
    for _ in range(q):
        p, x = MI()
        p -= 1
        point[p] += x

    d = deque([(0, point[0])])
    used = [0] * n
    used[0] = 1

    l = 1
    while l > 0:
        v, p = d.popleft()
        l -= 1
        for nv in e[v]:
            if used[nv]: continue
            used[nv] = 1
            point[nv] += p
            d.append((nv, point[nv]))
            l += 1

    printlist(point, " ")

if __name__ == '__main__':
    solve()
# Original solution
import sys

sys.setrecursionlimit(1000000)


n, q = [int(i) for i in input().split()]
ab = [[] for _ in range(n)]
for _ in range(n - 1):
    i, j = [int(i)-1 for i in input().split()]
    ab[i].append(j)
    ab[j].append(i)
p = [0]*n
for _ in range(q):
    i, j = [int(i) for i in input().split()]
    p[i-1] += j

al = [False]*n
pp = [0]*n


def a(i=0, j=0):
    al[i] = True
    j += p[i]
    pp[i] = str(j)
    for k in ab[i]:
        if not al[k]:
            a(k, j)


a()
print((" ".join(pp)))


# Optimized solution
import sys

sys.setrecursionlimit(1000000)


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


n, q = [int(i) for i in input().split()]
ab = [[] for _ in range(n)]
for _ in range(n - 1):
    i, j = [int(i)-1 for i in input().split()]
    ab[i].append(j)
    ab[j].append(i)
p = [0]*n
for _ in range(q):
    i, j = [int(i) for i in input().split()]
    p[i-1] += j

al = [False]*n
pp = [0]*n


def a(i=0, j=0):
    al[i] = True
    j += p[i]
    pp[i] = str(j)
    for k in ab[i]:
        if not al[k]:
            a(k, j)


a()
print((" ".join(pp)))
# Original solution
import sys
sys.setrecursionlimit(1000000)
def input():
    return sys.stdin.readline()

n, q = [int(i) for i in input().split()]
e = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = [int(i) - 1 for i in input().split()]
    e[a].append(b)
    e[b].append(a)

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


def dfs(i=0, r=-1, po=0):
    p[i] += po
    for j in e[i]:
        if j == r:
            continue
        dfs(j, i,p[i])
dfs()

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

# Optimized solution
import sys
sys.setrecursionlimit(1000000)

n, q = [int(i) for i in input().split()]
e = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = [int(i) - 1 for i in input().split()]
    e[a].append(b)
    e[b].append(a)

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


def dfs(i=0, r=-1, po=0):
    p[i] += po
    for j in e[i]:
        if j == r:
            continue
        dfs(j, i,p[i])
dfs()

print((" ".join(map(str,p))))
# Original solution
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def dfs(x):
        fx = f[x]
        for y in v[x]:
            if d[y]:
                d[y] = 0
                f[y] += fx
                dfs(y)
    n,q = LI()
    v = [[] for i in range(n)]
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    f = [0]*n
    for i in range(q):
        p,x = LI()
        p -= 1
        f[p] += x
    d = [1]*n
    d[0] = 0
    dfs(0)
    print(*f,sep=" ")
    return

#Solve
if __name__ == "__main__":
    solve()


# Optimized solution
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def dfs(x):
        fx = f[x]
        for y in v[x]:
            if d[y]:
                d[y] = 0
                f[y] += fx
                dfs(y)
    n,q = LI()
    v = [[] for i in range(n)]
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    f = [0]*n
    for i in range(q):
        p,x = LI()
        p -= 1
        f[p] += x
    d = [1]*n
    d[0] = 0
    q = deque([0])
    while q:
        x = q.popleft()
        fx = f[x]
        for y in v[x]:
            if d[y]:
                d[y] = 0
                f[y] += fx
                q.append(y)
    print(*f,sep=" ")
    return

#Solve
if __name__ == "__main__":
    solve()
# Original solution
import sys
from collections import deque
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return list(map(int, input().split()))
def MF(): return list(map(float,input().split()))
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]

def main():
    N, Q = MI()
    #木
    tree = [[]]*N
    visit = [True]*N
    for i in range(N-1):
        a,b = MI()
        if len(tree[a-1]) == 0:
            tree[a-1] = [b-1]
            tree[b-1] = [a-1]
        else:
            tree[a-1].append(b-1)
            tree[b-1].append(a-1)
    #カウンター保存用、初期化
    counter = [0]* N
    score = [0]* N
    dq = deque([0])
    visit[0] = False
    for i in range(Q):
        p, x = MI()
        counter[p-1] += x
    score[0] = counter[0]
    while dq:
        temp = dq.pop()
        for num in tree[temp]:
            if visit[num]:
                score[num] = score[temp]+counter[num]
                dq.append(num)
                visit[num] = False
    score = [str(i) for i in score]
    print((" ".join(score)))
    return None

if __name__ == "__main__":
    main()

# Optimized solution
import sys
from collections import deque
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return list(map(int, input().split()))
def MF(): return list(map(float,input().split()))
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]

def main():
    N, Q = MI()
    #木
    tree = [[] for i in range(N)]
    for i in range(N-1):
        a,b = MI()
        tree[a-1].append(b-1)
        tree[b-1].append(a-1)
    #カウンター保存用、初期化
    counter = [0]* N
    score = [0]* N
    dq = deque()
    dq.append([0,-1])
    for i in range(Q):
        p, x = MI()
        counter[p-1] += x
    score[0] = counter[0]
    #score[tree[0][0]] = counter[tree[0][0]]
    while dq:
        temp, past = dq.pop()
        for num in tree[temp]:
            if num != past:
                score[num] = score[temp]+counter[num]
                dq.append([num,temp])
    score = [str(i) for i in score]
    print((" ".join(score)))
    return None

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

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

queue = deque()

for _ in range(1, N):
    queue.append(tuple(map(int, input().split(' '))))

tree = {
    1: set()
}

while len(queue) > 0:
    a, b = queue.popleft()
    if a in tree:
        tree[a].add(b)
        tree[b] = set()
    elif b in tree:
        tree[b].add(a)
        tree[a] = set()
    else:
        queue.append((a, b))

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

stack = deque([1])

while len(stack) > 0:
    node = stack.popleft()
    for child in tree[node]:
        stack.append(child)
        results[child] += results[node]

print((' '.join([str(result) for result in results[1:]])))


# Optimized solution
from collections import deque, defaultdict

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

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

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

stack = deque([1])
searched = set()

while len(stack) > 0:
    node = stack.popleft()
    searched.add(node)
    for child in tree[node]:
        if child not in searched:
            stack.append(child)
            results[child] += results[node]

print((' '.join([str(result) for result in results[1:]])))
# Original solution
import sys

sys.setrecursionlimit(10000000)

N, Q = [int(x) for x in input().split()]
# V = [set() for _ in range(N)]
V = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = [int(x) for x in input().split()]
    a -= 1
    b -= 1
    # V[a].add(b)
    V[a].append(b)

C = [0] * N

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

ANS = [0] * N


def dfs(n, val):
    ANS[n] += (val + C[n])
    for next in V[n]:
        dfs(next, val + C[n])


def main():
    dfs(0, 0)
    print((" ".join([str(x) for x in ANS])))


if __name__ == '__main__':
    main()


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

sys.setrecursionlimit(10000000)

N, Q = [int(x) for x in input().split()]
# V = [set() for _ in range(N)]
V = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = [int(x) for x in input().split()]
    a -= 1
    b -= 1
    # V[a].add(b)
    V[a].append(b)

C = [0] * N

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

ANS = [0] * N


def dfs(n, val):
    ANS[n] += (val + C[n])
    for next in V[n]:
        dfs(next, val + C[n])


def main():
    dfs(0, 0)
    print((" ".join([str(x) for x in ANS])))


if __name__ == '__main__':
    main()
# 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

def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)

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


# Optimized solution
import sys
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

def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)

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