program kadai
implicit none

integer(8)  ::  n
integer(8)  ::  q
integer(8),allocatable  ::  a(:)
integer(8),allocatable  ::  b(:)
integer(8),allocatable  ::  p(:)
integer(8),allocatable  ::  x(:)
integer(8),allocatable  ::  counter(:)
integer(8),allocatable  ::  ans(:)
integer(8)  ::  i , j , k

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


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

call qsort(a,b)

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

ans=counter

do i=1,n-1
    ans(b(i))=ans(b(i))+ans(a(i))
end do

write(*,*) ans


stop
contains


!入れ替え!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine swap(a,b,f,g)
    implicit none
    integer(8),intent(inout)  ::  a,b,f,g
    integer(8)  ::  c,d
    c=a
    a=b
    b=c

    d=f
    f=g
    g=d
end subroutine swap

subroutine qsort(x,y)
    implicit none
    integer(8), intent(inout)  ::  x(:)
    integer(8), intent(inout)  ::  y(:)
    integer(8)  ::  first,last
    first=1
    last=size(x)
    call q2sort(x,y,first,last)
    return
end subroutine qsort

recursive subroutine q2sort(x,y,first,last)
    implicit none
    integer(8), intent(inout)  ::  x(:)
    integer(8), intent(inout)  ::  y(:)
    integer(8), intent(inout) ::  first,last
    integer(8)  ::  fir, las
    integer(8)  ::  i,j
    integer(8)  ::  n
    n=x((first+last)/2)
    i=first
    j=last
    do
        do while (x(i)<n)
            i=i+1
        end do
        do while(x(j)>n)
            j=j-1
        end do
        if (i>j .or. i==j) then
            exit
        end if
        call swap(x(i),x(j),y(i),y(j))
        i=i+1
        j=j-1
    end do
    if (first<i-1) then
        las=i-1
        call q2sort(x,y,first,las)
    end if
    if (last>j+1) then
        fir=j+1
        call q2sort(x,y,fir,last)
    end if
end subroutine q2sort

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


end program kadai
