n,m = map(int,input().split())
tree_list  = []
answer_list = [0]
for i in range(n-1):
    tree_list.append(list(map(int,input().split())))
    answer_list.append(0)
for i in range(m):
    num1,num2 = map(int,input().split())
    answer_list[num1-1] +=  num2
for i in range(n): 
    true = True
    while true:
        true = False
        print(i)
        for _ in tree_list:
            if i == _[0]-1:
                answer_list[_[1]-1] += answer_list[i]
                tree_list.remove(_)
                true = True
for i in answer_list:
    print(i)