let [|n; q|] = stdin.ReadLine().Split(' ') |> Array.map int
let mutable cache = Array.create n 0
let mutable refs = Array.create n None

for i in 1..(n - 1) do
    let [|a; b|] = stdin.ReadLine().Split(' ') |> Array.map int
    Array.set refs (b - 1) (Some(a - 1))

for i in 1..q do
    let [|p; x|] = stdin.ReadLine().Split(' ') |> Array.map int
    let value = Array.item (p - 1) cache
    Array.set cache (p - 1) (value + x)

for i in 0..(n - 1) do
    let refValue = match Array.item i refs with
                   | Some ref -> Array.item ref cache
                   | None -> 0
    let value = Array.item i cache
    Array.set cache i (refValue + value)

let rec printList lst =
    match lst with
    | [] -> printf "\n"
    | [x] -> printf "%d" x
    | x :: tail ->
         printf "%d " x
         printList tail

printList (Array.toList cache)
