N, Q = map(int, input().split())
edges = [input().split() for _ in range(N-1)]
operations = [input().split() for _ in range(Q)]

tree = {}
counter = [0]*N
result = [0]*N
numbers = []

for o in operations:
    counter[int(o[0])-1] += int(o[1])

result[0] = counter[0]

# print(counter)

for e in edges:
    parent = e[0]
    sun = e[1]
    if sun in numbers:
        sun = e[0]
        parent = e[1]
    else:
        numbers.append(sun)

    if sun in tree:
        tree[sun].append(parent)
    else:
        tree[sun] = [parent]

    if parent in tree:
        tree[sun].extend(tree[parent])


# print(tree)

for k in tree.keys():
    result[int(k)-1] += counter[int(k) - 1]
    for i in tree[k]:
        result[int(k)-1] += counter[int(i)-1]

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