Imports System.Collections.Generic
Public Class Program
  Shared Sub Main()
    Dim nq As Long() = Array.ConvertAll(Of String, Long)(Console.ReadLine().Split(" "), AddressOf Long.Parse)
    Dim n As Long = nq(0)
    Dim q As Long = nq(1)
    Dim vs(0 To n - 2, 0 To 1) As Long
    For i As Long = 0 To n - 2
      Dim ab As Long() = Array.ConvertAll(Of String, Long)(Console.ReadLine().Split(" "), AddressOf Long.Parse)
      vs(i, 0) = ab(0)
      vs(i, 1) = ab(1)
    Next
    Dim op(0 To q - 1, 0 To 1) As Long
    Dim x(0 To n - 1) As Long
    For i As Long = 0 To q - 1
      Dim px As Long() = Array.ConvertAll(Of String, Long)(Console.ReadLine().Split(" "), AddressOf Long.Parse)
      op(i, 0) = px(0)
      op(i, 1) = px(1)
      x(op(i, 0) - 1) += op(i, 1)
    Next
    Dim edge(0 To n - 1) As List(Of Long)
    Dim ans(0 To n - 1) As Long
    Dim visited(0 To n - 1) As Boolean
    For i As Long = 0 To n - 1
      edge(i) = New List(Of Long)()
      ans(i) = 0
      visited(i) = False
    Next
    For i As Long = 0 To n - 2
      edge(vs(i, 0) - 1).Add(vs(i, 1) - 1)
      edge(vs(i, 1) - 1).Add(vs(i, 0) - 1)
    Next
    Dim targetRoot As List(Of Long) = New List(Of Long)()
    targetRoot.Add(0)
    While targetRoot.Count > 0
      Dim r As List(Of Long) = New List(Of Long)(targetRoot)
      targetRoot.Clear()
      For Each i As Long In r
        ans(i) += x(i)
        visited(i) = True
        For Each j As Long In edge(i)
          If Not visited(j) Then
            ans(j) = ans(i)
            targetRoot.Add(j)
          End If
        Next
      Next
    End While
    Console.WriteLine(String.Join(Of Long)(" ", ans))
  End Sub
End Class