let n, q = Scanf.scanf " %d %d" @@ fun a b -> a, b
let g = Array.make n []
let _ = for _ = 1 to n - 1 do Scanf.scanf " %d %d" @@ fun u v -> g.(u - 1) <- v - 1 :: g.(u - 1); g.(v - 1) <- u - 1 :: g.(v - 1) done
let pxs = Array.init q @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a - 1, b
let os, ans = Array.(make n 0, make n 0)
let rec f v p x = ans.(v) <- x + os.(v); List.iter (fun u -> if u <> p then f u v @@ x + os.(v)) g.(v)
let _ = Array.(iter (fun (p, x) -> os.(p) <- os.(p) + x) pxs; f 0 ~-1 0; iteri (fun i n -> Printf.printf (if i = 0 then "%d" else " %d") n) ans; print_newline ())