program main
	implicit none
    integer n,q,a,b,p,x,i,st_size,u,v
    integer,allocatable::d(:),g(:,:),ans(:),st(:)
    logical,allocatable::f(:)
	read *,n,q
    allocate(d(n))
    d=0
    allocate(g(n,n))
    allocate(ans(n))
    allocate(st(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.
    st(1)=1
    st_size=1
    do
    	if(st_size==0) exit
        v=st(st_size)
        st_size=st_size-1
        f(v)=.false.
        do i=1,d(v)
        	u=g(v,i)
            if(f(u)) then
            	ans(u)=ans(u)+ans(v)
                st_size=st_size+1
                st(st_size)=u
            end if
        end do
    end do
    print '(i0)', ans
end program main