
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord

import qualified Data.IntMap as M
import qualified Data.Sequence as S

import Data.Foldable

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)


main :: IO ()
main = do
    [n,q] <- r' :: IO [Int]

    ab <- replicateM (n-1) $ do
        [a,b] <- r'
        return (a, S.singleton b)
    
    let mp = M.fromListWith (S.><) ab :: M.IntMap (S.Seq Int)


    px <- replicateM q rp

    let pMap = M.fromListWith (+) px :: M.IntMap Int

    let slMp = solve 1 0 mp pMap
    putStrLn $ intercalate " " $ map (show . snd) (nub $ sortBy (comparing fst) $ toList slMp)


solve :: Int -> Int -> M.IntMap (S.Seq Int) -> M.IntMap Int -> S.Seq (Int,Int)
solve pos vac mp pMap =
    let curVal = case M.lookup pos pMap of
                    Just v -> v
                    Nothing -> 0
        nVal  = curVal + vac
        nacMp = (pos,nVal)
    in  case M.lookup pos mp of
            Just children ->
                --traceShow (pos,vac,val,nVal) $
                    do
                        nPos <- children
                        nacMp S.<| (solve nPos nVal mp pMap)
            Nothing -> return nacMp
