import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as MP
import qualified Data.Set as ST
import qualified Data.Sequence as SQ
import Data.Array.Unboxed
import Data.Array.IO
import Data.Maybe
import Data.Ratio
import Data.Char
import Data.Bits
import Data.List
import Data.Tuple
import Data.Functor
import Data.IORef
import Data.STRef
import Control.Applicative
import Control.Monad
import Control.Monad.ST

buildGraph :: V.Vector (Int, Int) -> Int -> V.Vector (VU.Vector Int)
buildGraph edges n = V.accumulate step (V.replicate n VU.empty) edges
  where
    step vec v = VU.cons v vec

toTuple :: B.ByteString -> (Int, Int)
toTuple bs =
    let
      Just (a,bs') = B.readInt bs 
      Just (b,_) = B.readInt $ B.dropWhile isSpace bs'
    in (a,b)

dfs :: V.Vector (VU.Vector Int) -> VUM.IOVector Int -> Int -> Int -> IO ()
dfs graph table v p = VUM.read table v >>= \r -> (VU.forM_ ns $ \n -> unless (n==p) $ VUM.modify table (+r) n >> dfs graph table n v)
  where
    ns = graph V.! v

main = do
  [n,q] <- map read . words <$> getLine :: IO [Int]
  graph <- flip buildGraph n <$> (V.replicateM (n-1) $ B.getLine >>= return . (\(a,b) -> (a-1,b-1)) . toTuple)
  query <- VU.replicateM q (B.getLine >>= return . (\(a,b) -> (a-1,b)) . toTuple)
  table <- VUM.replicate n 0 :: IO (VUM.IOVector Int)
  res <- VUM.replicate n 0 :: IO (VUM.IOVector Int)
  VU.forM_ query $ \(v,n) -> VUM.modify table (+n) v
  dfs graph table 0 (-1)
  VU.unsafeFreeze table >>= putStrLn . unwords . map show . VU.toList