
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)


data Tree a = Node Int a [Tree a] deriving Show


buildTree :: Int -> Int -> M.IntMap ([Int],Int) -> Tree Int 
buildTree pos ac mp =
    case M.lookup pos mp of
        Just (xs,v) -> Node pos (ac+v) [ buildTree x (ac+v) mp | x<-xs]

flatten :: Tree Int -> U.Vector (Int,Int)
flatten (Node pos v chil) = U.cons (pos,v) (U.concat $ map flatten chil)

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
    let tree = buildTree 1 0 sMp
    -- print slMp
    --putStrLn $ intercalate " " $ map (show . snd) (M.toAscList slMp)
    putStrLn $ intercalate " " $ map (show . snd) $ sortBy (comparing fst) (U.toList $ flatten tree)




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
