stdin.ReadLine()
|> fun x -> x.Split(' ') |> Array.map int |> fun x -> (x.[0], x.[1])
|> fun (n, q) ->
  (
    [1..(n - 1)] |> List.map (fun _ -> stdin.ReadLine() |> fun x -> x.Split(' ') |> Array.map int |> fun x -> (x.[0], x.[1])),
    [1..q]       |> List.map (fun _ -> stdin.ReadLine() |> fun x -> x.Split(' ') |> Array.map int |> fun x -> (x.[0], x.[1]))
  )
  |> fun (ns, qs) ->
    (
      ns
      |> List.fold (
        fun map (a, b) ->
          map
          |> Map.tryFind a
          |> fun t ->
            match t with
            | Some cs -> map.Remove(a).Add(a, b::cs)
            | None -> map.Add(a, [b])
      ) Map.empty,
      (0, 1)::ns
      |> List.map (fun (a, b) -> (b, a))
      |> Map.ofList,
      qs
      |> List.fold (
        fun (arr: int64 array) (p, x) ->
          (arr.[p] <- arr.[p] + int64 x)
          |> fun () -> arr
      ) (Array.zeroCreate (n + 1))
    )
    |> fun (pcs, ps, (arr: int64 array)) ->
        ([| [1] |])
        |> fun (stack: int list array) ->
          Seq.initInfinite (
            fun _ ->
              match stack.[0] with
              | [] -> ()
              | i::ts ->
                ps
                |> Map.find i
                |> fun pi -> (arr.[i] <- arr.[pi] + arr.[i])
                |> fun () ->
                  pcs
                  |> Map.tryFind i
                  |> fun cs ->
                    match cs with
                    | Some cs -> (stack.[0] <- cs @ ts)
                    | None -> (stack.[0] <- ts)
          )
          |> Seq.takeWhile (fun _ -> stack.[0] |> List.isEmpty |> not)
          |> Seq.toArray
          |> fun _ -> arr
|> fun arr ->
  arr
  |> Array.skip 1
  |> Array.map string
  |> String.concat " "
|> printfn "%s"
