stdin.ReadLine()
|> fun x -> x.Split() |> Array.map int |> fun x -> (x.[0], x.[1])
|> fun (n, q) ->
  (
    List.init (n - 1) (fun _ -> stdin.ReadLine() |> fun x -> x.Split() |> Array.map int |> fun x -> (x.[0], x.[1])),
    List.init q       (fun _ -> stdin.ReadLine() |> fun x -> x.Split() |> Array.map int |> fun x -> (x.[0], x.[1]))
  )
  |> fun (nabs, qpxs) ->
    (
      (
        (Array.create (n + 1) [])
        |> fun (edges: int list array) ->
          nabs
          |> List.iter (
            fun  (a, b) ->
              (
                (edges.[a] <- b::edges.[a]),
                (edges.[b] <- a::edges.[b])
              )
              |> ignore
          )
          |> fun () -> edges
      ),
      (
        (Array.zeroCreate (n + 1))
        |> fun (points: int array) ->
          qpxs
          |> List.iter (
            fun (p, x) ->
              (points.[p] <- points.[p] + x)
          )
          |> fun () -> points
      )
    )
  |> fun (edges, points) ->
    (
      [| [(0, 1)] |],
      Array.concat [ [| 0 |]; Array.create (n) (-1) ]
    )
    |> fun ((stack: (int * int) list array), (ret: int array)) ->
      Seq.initInfinite (
        fun _ ->
          match stack.[0] with
          | [] -> ()
          | (pi, ci)::ts ->
            (ret.[ci] <- ret.[pi] + points.[ci])
            |> fun () ->
              match edges.[ci] with
              | [] -> (stack.[0] <- ts)
              | cs ->
                cs
                |> List.filter ((<>) pi)
                |> List.map (fun i -> (ci, i))
                |> fun hs -> (stack.[0] <- (hs @ ts))
      )
      |> Seq.takeWhile (fun _ -> stack.[0] |> List.isEmpty |> not)
      |> Seq.length
    |> fun _ -> ret
|> fun ret ->
  ret
  |> Array.skip 1
  |> Array.map string
  |> String.concat " "
|> printfn "%s"
