program kadai
implicit none

integer  ::  n
integer  ::  q
integer,allocatable  ::  a(:)
integer,allocatable  ::  b(:)
integer,allocatable  ::  p(:)
integer,allocatable  ::  x(:)
integer,allocatable  ::  counter(:)
integer  ::  i

read(*,*) n,q
allocate(a(n-1))
allocate(b(n-1))
allocate(p(q))
allocate(x(q))
allocate(counter(n))


do i=1,n-1
    read(*,*) a(i),b(i)
end do

do i=1,q
    read(*,*) p(i),x(i)
end do

counter=0

do i=1,q
    counter(p(i))=counter(p(i))+x(i)
end do



call plus(a,b,counter,1,n)

write(*,*) counter


stop
contains

recursive subroutine plus(a,b,counter,num,n)
    implicit none
    integer, intent(inout)  ::  a(:),b(:),counter(:)
    integer, intent(in)  ::  num,n
    integer  ::  next
    integer  ::  i
    next=0
    i=1
    do i=1,n-1
        if (a(i)==num) then
            counter(b(i)) = counter(b(i)) + counter(num)
            next=b(i)
            a(i)=10**6
            b(i)=10**6
            call plus(a,b,counter,next,n)
        else if (b(i)==num) then
            counter(a(i)) = counter(a(i)) + counter(num)
            next=a(i)
            a(i)=10**6
            b(i)=10**6
            call plus(a,b,counter,next,n)
        end if
    end do

    return
    stop
end subroutine plus

end program kadai
