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.Strict as MPS
import Control.Monad
import Data.Char
import Data.Tuple

buildGraph :: V.Vector (Int, Int) -> Int -> V.Vector (VU.Vector Int)
buildGraph edges n = V.accumulate step (V.replicate n VU.empty) (V.map swap edges V.++ 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]
  table <- VUM.replicate n 0 :: IO (VUM.IOVector Int)
  graph <- flip buildGraph n <$> (V.replicateM (n-1) $ B.getLine >>= return . (\(a,b) -> (a-1,b-1)) . toTuple)
  query <- replicateM_ q $ do
    (v,n) <- B.getLine >>= return . (\(a,b) -> (a-1,b)) . toTuple
    VUM.modify table (+n) v
  dfs graph table 0 (-1)
  table' <- VU.unsafeFreeze table
  VU.forM_ table' $ \x -> putStr $ show x ++ " "
  putStrLn ""