str = gets.split
N,Q = str[0].to_i, str[1].to_i
a = Array.new(N+1){Array.new(0)}
b = Array.new(N+1,0)
c = Array.new(0)
x,y = 0,0
for i in 1...N do
    str = gets.split
    x,y = str[0].to_i, str[1].to_i
    a[x].push(y)
    a[y].push(x)
end
for i in 0...Q do
    str = gets.split
    x,y = str[0].to_i, str[1].to_i
    b[x] += y
end

for i in 0...a[1].size do
    c.push(1)
    c.push(a[1][i])
end

d = 0
while !c.empty?
    d = c.pop
    a[d].delete(c.pop)
    for i in 0...a[d].size do
        c.push(d)
        c.push(a[d][i])
    end
end

while !a[1].empty?
    c.push(1)
    c.push(a[1].pop)
end
while !c.empty?
    d = c.pop
    b[d] += b[c.pop]
    while !a[d].empty?
        c.push(d)
        c.push(a[d].pop)
    end
end

for i in 1..N do
    print b[i]," "
end
puts