from sys import stdin,setrecursionlimit

from itertools import groupby

setrecursionlimit(10**6) 

n,q = [int(x) for x in stdin.readline().rstrip().split()]

li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n-1)]

lin = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]

kazu = [[]for _ in range(n+1)]

point = [0]*(n+1)

for i in li:

    kazu[i[0]].append(i[1])

    kazu[i[1]].append(i[0])

for i in lin:

    point[i[0]] += i[1]

def dfs(now,before):

    for i in (kazu[now]):

        if i == before:

            continue

        point[i] += point[now]

        dfs(i,now)

dfs(1,0)

print((*point[1:]))
from collections import defaultdict

from sys import setrecursionlimit

setrecursionlimit(10 ** 7)



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



node = [[] for _ in range(n+1)]

counter = [0 for _ in range(n+1)]

visited = [0 for _ in range(n+1)]

point_dic = defaultdict(int)



for _ in range(n-1):

    a,b = list(map(int,input().split()))

    node[a].append(b)

    node[b].append(a)



for _ in range(q):

    p,x = list(map(int,input().split()))

    point_dic[p] += x



def dfs(now,before):

    global counter

    global visited



    if visited[now]:

        return

    

    if point_dic[now]:

        point = point_dic[now]+before

    else:

        point = before

    

    visited[now] = 1

    counter[now] += point



    for i in node[now]:

        if visited[i]:

            continue



        dfs(i,point)



dfs(1,0)



print((' '.join(map(str, counter[1:]))))
from sys import stdin, setrecursionlimit
from itertools import groupby

setrecursionlimit(10**6)
n, q = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int, stdin.readline().rstrip().split())) for _ in range(n - 1)]
lin = [list(map(int, stdin.readline().rstrip().split())) for _ in range(q)]
kazu = [[] for _ in range(n + 1)]
point = [0] * (n + 1)
for i in li:
    kazu[i[0]].append(i[1])
    kazu[i[1]].append(i[0])
for i in lin:
    point[i[0]] += i[1]


def dfs(now, before):
    for i in kazu[now]:
        if i == before:
            continue
        point[i] += point[now]
        dfs(i, now)


dfs(1, 0)
print((*point[1:]))

from collections import defaultdict
from sys import setrecursionlimit

setrecursionlimit(10**7)
n, q = list(map(int, input().split()))
node = [[] for _ in range(n + 1)]
counter = [0 for _ in range(n + 1)]
visited = [0 for _ in range(n + 1)]
point_dic = defaultdict(int)
for _ in range(n - 1):
    a, b = list(map(int, input().split()))
    node[a].append(b)
    node[b].append(a)
for _ in range(q):
    p, x = list(map(int, input().split()))
    point_dic[p] += x


def dfs(now, before):
    global counter
    global visited
    if visited[now]:
        return
    if point_dic[now]:
        point = point_dic[now] + before
    else:
        point = before
    visited[now] = 1
    counter[now] += point
    for i in node[now]:
        if visited[i]:
            continue
        dfs(i, point)


dfs(1, 0)
print((" ".join(map(str, counter[1:]))))

-from sys import stdin, setrecursionlimit -from itertools import groupby +from collections import defaultdict +from sys import setrecursionlimit -setrecursionlimit(10**6) -n, q = [int(x) for x in stdin.readline().rstrip().split()] -li = [list(map(int, stdin.readline().rstrip().split())) for _ in range(n - 1)] -lin = [list(map(int, stdin.readline().rstrip().split())) for _ in range(q)] -kazu = [[] for _ in range(n + 1)] -point = [0] * (n + 1) -for i in li: -    kazu[i[0]].append(i[1]) -    kazu[i[1]].append(i[0]) -for i in lin: -    point[i[0]] += i[1] +setrecursionlimit(10**7) +n, q = list(map(int, input().split())) +node = [[] for _ in range(n + 1)] +counter = [0 for _ in range(n + 1)] +visited = [0 for _ in range(n + 1)] +point_dic = defaultdict(int) +for _ in range(n - 1): +    a, b = list(map(int, input().split())) +    node[a].append(b) +    node[b].append(a) +for _ in range(q): +    p, x = list(map(int, input().split())) +    point_dic[p] += x -    for i in kazu[now]: -        if i == before: +    global counter +    global visited +    if visited[now]: +        return +    if point_dic[now]: +        point = point_dic[now] + before +    else: +        point = before +    visited[now] = 1 +    counter[now] += point +    for i in node[now]: +        if visited[i]: -        point[i] += point[now] -        dfs(i, now) +        dfs(i, point) -print((*point[1:])) +print((" ".join(map(str, counter[1:]))))