n, q = map(int,input().split())
top_list = [list(map(int,input().split())) for i in range(n - 1)]
ope_list = [list(map(int,input().split())) for i in range(q)]
ans = [0] * n

"""
for i in ope_list:
    ans[i[0] - 1] += i[1]

for j in range(n):
    for k in top_list:
        if j + 1 == k[1]:
            ans[j] += ans[k[0] - 1]
"""

print(*ans)