### BUGGY CODE ###

import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def s_list(): return list(input())
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def num__grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]

n, q = wi()
ab = mi(n - 1)
px = mi(q)
numdict = {}
for i in range(n + 1):
    numdict[i] = []

parli = [0 for i in range(n + 1)]
parli[1] = 1
for i in range(n - 1):
    if parli[ab[i][0]] == 0:
        parli[ab[i][0]] = 1
    else:
        numdict[ab[i][0]].append(ab[i][1])
    if parli[ab[i][1]] == 0:
        parli[ab[i][1]] = 1
    else:
        numdict[ab[i][1]].append(ab[i][0])

numli = [0 for i in range(n + 1)]

plsdict = defaultdict(int)
for i in range(q):
    plsdict[px[i][0]] += px[i][1]

for i in range(1, n + 1):
    numli[i] += plsdict[i]



queue = deque()
queue.append(1)
while queue != deque():
    po = queue.popleft()
    for kk in numdict[po]:
        queue.append(kk)
        numli[kk] += numli[po]

for i in range(1, n + 1):
    print(numli[i],"" , end="")


### FIXED CODE ###

import sys
from collections import defaultdict
def wi(): return list(map(int, sys.stdin.readline().split()))
def i(): return int(sys.stdin.readline())
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def mip(n): return [wip() for _ in range(n)]

def main():
    n, q = wi()
    ab = mip(n - 1)
    px = mip(q)
    for i in range(q):
        px[i][1] += 1


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

    son = [[] for _ in range(n)]
    for i in range(n - 1):
        son[ab[i][0]].append(ab[i][1])
        son[ab[i][1]].append(ab[i][0])

    flagli = [0] * n
    flagli[0] = 1
    queue = []
    queue.append(0)
    while queue != []:
        po = queue.pop()
        for kk in son[po]:
            if flagli[kk] == 0:
                flagli[kk] = 1
                queue.append(kk)
                cost[kk] += cost[po]

    for i in range(n):
        print(cost[i],"" , end="")

if __name__ == '__main__':
    main()