lines = []
while line = gets
  line.chomp!
  lines.push(line)
end

fl = lines[0].split
n = fl[0].to_i
q = fl[1].to_i

# array = Array.new(n+1, [])
$array = []
(n+1).times do
    $array.push([])
end

$ansArray = Array.new(n+1, 0)

for e in 1..lines.length - q - 1
    ar = lines[e].split
    $array[ar[0].to_i].push(ar[1].to_i)
end


def fib(a, b)
  $ansArray[a] += b
  if $array[a] != [] then
     $array[a].each do |x|
          fib(x, b)
     end
  end
end


for e in (lines.length - q)...lines.length
    y = lines[e].split
    fib(y[0].to_i, y[1].to_i)
end
$ansArray.shift()
print $ansArray.join(" ")

