#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from collections import deque

# N: ノードの数
# Q: 数値をノードに付与する回数
N, Q = list(map(int, input().split()))

links =  [[] for _ in range(N)]
values = [0 for _ in range(N)]

for i in range(N - 1):
    edge1, edge2 = [x - 1 for x in list(map(int, input().split()))]
    links[edge1].append(edge2)
    links[edge2].append(edge1)

for i in range(Q):
    node, val = list(map(int, input().split()))
    values[node - 1] += val

# 値の計算
stack = deque()
stack.append((0, -1))
while stack:
    node = stack.pop()

    for linked_node in links[node[0]]:
        if linked_node == node[1]:  # link が親ノード向けでなければ
            continue

        values[linked_node] += values[node[0]]
        stack.append((linked_node, node[0]))

print(*values)