import Control.Monad ( replicateM )
import Data.Tree ( flatten, Tree(Node) )
import Data.Array ( (!), accumArray, array, elems, Array )
import Data.Graph ( Tree(..), buildG, dfs )
import Data.Maybe ( fromJust )
import Data.Tuple ( swap )
import qualified Data.ByteString.Char8 as BS

scanTree :: (b -> a -> b) -> b -> Tree a -> Tree b
scanTree f z (Node x ts) = Node xx (map (scanTree f xx) ts)
    where xx = f z x

accumCount :: Array Int Int -> (Int, Int) -> Int -> (Int, Int)
accumCount counts acc vertex = (vertex, snd acc + counts!vertex)

solve :: Int -> [(Int, Int)] -> Int -> [(Int, Int)] -> [Int]
solve n e q px = elems countArray
    where
        counts = accumArray (+) 0 (1, n) px
        graph = buildG (1, n) (e ++ map swap e)
        tree = (head . dfs graph) [1]
        accumulatedTree = scanTree (accumCount counts) (0, 0) tree
        countArray = array (1, n) (flatten accumulatedTree)

tuplify2 :: [a] -> (a, a)
tuplify2 (x:y:_) = (x,y)

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

main :: IO ()
main = do
    [n, q] <- map readInt . BS.words <$> BS.getLine
    e <- replicateM (n - 1) (tuplify2 . map readInt . BS.words <$> BS.getLine)
    px <- replicateM q (tuplify2 . map readInt . BS.words <$> BS.getLine)
    putStrLn $ unwords $ map show $ solve n e q px
