program main
	implicit none
    integer n,q,a,b,p,x,i
    integer,allocatable::d(:),g(:,:),ans(:)
    logical,allocatable::f(:)
	read *,n,q
    allocate(d(n))
    d=0
    allocate(g(n,n))
    allocate(ans(n))
    allocate(f(n))
    do i=1,n-1
    	read *,a,b
        d(a)=d(a)+1
        d(b)=d(b)+1
        g(a,d(a))=b
        g(b,d(b))=a
    end do
    ans=0
    do i=1,q
    	read *,p,x
        ans(p)=ans(p)+x
    end do
    f=.true.
    call dfs(g,d,f,1,ans)
    print '(i0)', ans
contains
	recursive subroutine dfs(g,d,f,v,s)
    	integer,intent(in)::g(:,:),d(:),v
        integer,intent(inout)::s(:)
        logical,intent(inout)::f(:)
        integer i,u
        f(v)=.false.
        do i=1,d(v)
    		u=g(v,i)
            if (f(u)) then
            	s(u)=s(u)+s(v)
                call dfs(g,d,f,u,s)
            end if
        end do
    end subroutine dfs
end program main