
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)
    
    px <- replicateM q rp


    let preMap = M.fromListWith (S.><) ab :: M.IntMap (S.Seq Int)
    let mp = insertLeafs n preMap
    --print mp

    let iniMp = M.map (\s -> (toList s,0)) mp :: M.IntMap ([Int], Int)

    let sMp = addCount px iniMp
    --print px
    --print sMp

    let slMp = solve 1 0 sMp M.empty
    -- print slMp
    putStrLn $ intercalate " " $ map (show . snd) (M.toAscList slMp)

insertLeafs :: Int -> M.IntMap (S.Seq Int) -> M.IntMap (S.Seq Int)
insertLeafs 0 mp = mp
insertLeafs n mp =
    let nMp = M.insertWith (flip const) n S.empty mp
    in  insertLeafs (n-1) nMp


addCount :: [(Int,Int)] -> M.IntMap ([Int], Int) -> M.IntMap ([Int], Int)
addCount [] cMp = cMp
addCount ((p,x):pxs) cMp =
    let nMp = M.update (\(s,a) -> Just (s,x+a)) p cMp
    in  addCount pxs nMp


solve :: Int -> Int -> M.IntMap ([Int], Int) -> M.IntMap Int -> M.IntMap Int 
solve pos vac mp acMp =
    let Just (children,val) = M.lookup pos mp
        nVal  = val+vac
        nacMp = M.insert pos nVal acMp
    in  --traceShow (pos,vac,val,nVal) $
        M.unions $ nacMp:[ solve nPos nVal mp nacMp | nPos <- children] 




