module pair_stack
    implicit none
    private
    integer, allocatable:: stack(:,:)
    integer:: depth, max_depth
    public:: init, pop, push, is_remaining

contains
    subroutine init(x)
        integer, intent(in):: x
        max_depth = x
        allocate(stack(2,x))
        stack(:, :) = 0
        depth = 0
    end subroutine

    subroutine pop(a, b)
        integer, intent(out):: a, b
        if (depth <= 0)stop '-- --Stack is empty'
        a = stack(1, depth)
        b = stack(2, depth)
        depth = depth - 1
        ! print*, '-- -- poped =>', a, b
    end subroutine

    subroutine push(a, b)
        integer, intent(in):: a, b
        if (depth >= max_depth)stop '-- --Stack over flow'
        ! print*, '-- -- pushed =>', a, b
        depth = depth + 1
        stack(1, depth) = a
        stack(2, depth) = b
    end subroutine

    function is_remaining() result(ret)
        logical:: ret
        if (depth <= 0)then
            ret = .false.
        else
            ret = .true.
        end if
    end function
end module


program main
    implicit none
    integer:: N, Q
    integer, allocatable:: ab(:, :), px(:, :), counter(:)
    integer:: i

    read*, N,Q
    allocate(ab(2, N-1), px(2, Q), counter(N))
    read*, ab(1:2, 1:N-1)
    read*, px(1:2, 1:Q)
    counter(1:N) = 0
    
    do i=1,Q
        counter(px(1,i)) = counter(px(1, i)) + px(2,i) 
    end do

    !call quick_sort(ab)

    do i=1,N-1
        counter(ab(2,i)) = counter(ab(2,i)) + counter(ab(1,i))
    end do

    do i = 1, N-1
        write(*, '(i0,1x)',advance='no')counter(i)
    end do
    write(*,'(i0)')counter(N)
    


contains
    subroutine quick_sort(arr)
        use pair_stack
        integer, intent(inout):: arr(:, :)
        integer:: left, right, pl, pr
        integer:: pv
        call init(int(log10(real(size(arr(1, :)))) + 10))
        call push(1,size(arr(1, :)))
        do while(is_remaining())
            ! print*, '-- -- 1'
            call pop(left, right)
            pl = left; pr = right
            pv = (left+right)/2
            ! print*, '-- left, right, pv =>', left, right, pv
            do while(pl <= pr)
                ! print*, '-- serch_exchange'
                do while(arr(1, pl) < arr(1, pv))
                    pl = pl + 1
                end do
                ! print*, '-- -- left >>', pl, arr(1, pl), arr(1, pv)

                do while(arr(1, pr) > arr(1, pv))
                    pr = pr - 1
                end do
                ! print*, '-- -- right >>', pr, arr(1, pr), arr(1, pv)

                if(pl <= pr)then
                    call swap(arr(1,pl), arr(1,pr))
                    call swap(arr(2,pl), arr(2,pr))
                    pl = pl + 1
                    pr = pr - 1
                    ! print*, '-- -- swapped'

                end if
            end do

            if((pl-1)-left >= right - pl)then
                if(pl < right)then
                    call push(left, pl-1)
                    call push(pl, right)
                else if(left < pr-1)then
                    call push(left, pl-1)
                end if
            else
                if(left < pl-1) then
                    call push(pl, right)
                    call push(left, pl-1)
                else if(pl < right)then
                    call push(pl, right)
                end if
            end if
        end do
    end subroutine

    subroutine swap(a,b)
        integer, intent(inout):: a,b
        integer:: r
        r = a; a = b; b = r
    end subroutine
end program main