module mod_tree
  implicit none
  type arraylist
    integer :: num = 0
    integer, pointer :: arr(:) => null()
  end type
  type tree
    type(arraylist), pointer :: egs(:) => null()
    integer, pointer :: dist(:) => null()
  contains
    procedure :: add => add
    procedure :: dfs => dfs
  end type
  interface tree
    module procedure :: newt
  end interface tree
contains
  subroutine appende(a)
    integer, pointer, intent(inout) :: a(:)
    integer :: n
    integer, allocatable :: tmp(:)
    n = size(a)
    allocate(tmp(n))
    tmp = a
    deallocate(a)
    allocate(a(2*n))
    a(1:n) = tmp
    deallocate(tmp)
  end
  subroutine adde(list,e)
    class(arraylist), intent(inout) :: list
    integer, intent(in) :: e
    if (.not.associated(list%arr)) allocate(list%arr(1))
    if (list%num == size(list%arr)) call appende(list%arr)
    list%num = list%num+1
    list%arr(list%num) = e
  end
  function gete(list,i) result(ret)
    class(arraylist), intent(inout) :: list
    integer, intent(in) :: i
    integer :: ret
    ret = list%arr(i)
  end
  function newt(n) result(ret)
    integer, intent(in) :: n
    type(tree) :: ret
    allocate(ret%egs(n))
    allocate(ret%dist(n))
    ret%dist = 0
  end
  subroutine add(this,fm,to)
    class(tree), intent(inout) :: this
    integer, intent(in) :: fm, to
    call adde(this%egs(fm),to)
  end
  recursive subroutine dfs(this,v,p,d)
    class(tree), intent(inout) :: this
    integer, intent(in) :: v, p, d
    integer :: n, i, u
    this%dist(v) = d
    n = this%egs(v)%num
    do i = 1, n
      u = gete(this%egs(v),i)
      if (u == p) cycle
      call dfs(this,u,v,d+1)
    end do
  end
end module mod_tree
program abc138d
    use mod_tree
    implicit none
    integer::N,Q,P,X
    integer::i
    integer,allocatable,dimension(:)::U,T,A,B
    integer(8),allocatable,dimension(:)::D
    logical,allocatable,dimension(:)::Visited
    type(tree)::G
    read*,N,Q
    allocate(U(0:N),T(0:N),D(N),A(N-1),B(N-1))
    G=tree(N)
    do i=1,N-1
        read*,A(i),B(i)
        call add(G,A(i),B(i))
        call add(G,B(i),A(i)) 
    end do
    call dfs(G,1,-1,0)
    U=0;T=0
    do i=1,N-1
        if(G%dist(A(i))<G%dist(B(i)))then
            U(B(i))=A(i)
        else
            U(A(i))=B(i)
        endif
    end do

    do i=1,Q
        read*,P,X
        T(P)=T(P)+X
    end do
    
    allocate(Visited(0:N))
    Visited=.false.
    do i=1,N
        if(.not.visited(i))then
            call solve(i)
        endif
        print"(i0)",T(i)
    end do
contains
recursive subroutine solve(Num)
    integer::Num
    if(U(Num)/=0.and. .not.(Visited(U(Num))))then
        call solve(U(Num))
    endif
    T(Num)=T(Num)+T(U(Num))
    Visited(Num)=.true.
end subroutine
end program