import Data.Array
import Data.List (sort)
import Control.Monad

main = do
  li <- getLine
  let [n,q] = map read $ words li
  bas <- forM [2..n] (\_ -> do
    li <- getLine
    let [a,b] = map read $ words li
    return (b,a)
    )
  pxs <- forM [1..q] (\_ -> do
    li <- getLine
    let [p,x] = map read $ words li
    return (p,x)
    )
  let ans = compute n q bas pxs
  putStrLn $ unwords $ map show ans

compute :: Int -> Int -> [(Int,Int)] -> [(Int,Int)] -> [Int]
compute n _ bas pxs = elems sa
  where
    xa = accumArray (+) 0 (1,n) pxs
    xs = elems xa
    sa = listArray (1,n) ( head xs : [ x + sa ! i | (x,(_,i)) <- zip (tail xs) (sort bas) ])
