import Data.Array.Unboxed

main = do
  s <- getLine
  let [n,q] = map (read :: String -> Int) $ words s
  let arr = array (1,n) [(i,0) | i <- [1..n]] :: UArray Int Int

  prt q arr

prt q arr = do
  if q == 0
     then return()
     else do
       s' <- getLine
       let s = map read $ words s'
       if head s == 0
          then
            prt (q-1)  (acm (tail s) arr)
          else do
            print $ arr ! (last s)
            prt (q-1) arr

acm [a,b,x] arr =  accum (+) arr (zip [a..b] [x,x..])