open System
open System.Collections.Generic

let toTuple xs =
    match xs with
    | [| a ; b |] -> (a, b)
    | _           -> failwith "invalid arguments"

let readIntTuple () =
    Console.ReadLine ()
    |> fun s -> s.Split(' ')
    |> Array.map int
    |> toTuple

let dfsFactory (G: list<int> array) (Q: Dictionary<int,int>) =
    let rec dfs p acc =
        let add = if Q.ContainsKey p then Q.Item p else 0

        printfn "%i" (acc + add)

        for child in G.[p] do
            dfs child (acc + add)

        ()

    dfs

[<EntryPoint>]
let main argv =
    let N, Q = readIntTuple ()

    let edges = seq { for _ in 1 .. N - 1 -> readIntTuple () }
                |> Seq.map (fun (a, b) -> (a - 1, b - 1))

    let queries' = seq { for _ in 1 .. Q -> readIntTuple () }
                   |> Seq.map (fun (p, q) -> (p - 1, q))

    let G = [| for _ in 1 .. N -> [] |]

    for a, b in edges do
        G.[a] <- b :: G.[a]

    for p in 0 .. N - 1 do
        G.[p] <- List.rev G.[p]

    let queries = new Dictionary<int, int> ()

    for p, q in queries' do
        if queries.ContainsKey p then
            queries.Item p <- queries.Item p + q
        else
            queries.Add (p, q)

    let dfs = dfsFactory G queries

    dfs 0 0

    0
