import Control.Applicative
import Control.Monad.State

data SegTree a = Leaf a 
               | Tree { size :: Int
                      , toBePlused :: a
                      , left :: (SegTree a)
                      , right :: (SegTree a)
                      } deriving (Show)

main = do
    [n,q] <- map read.words<$>getLine
    let init = fromList $ replicate n 0
    evalStateT (query q) init

query 0 = return ()
query n = getQuery >> query (n-1)

getQuery = do
    (x:xs) <- lift $ map read.words<$>getLine
    case x of
      0 -> let [s,t,x] = xs in modify (addT s t x)
      1 -> let [i] = xs in get >>= \tr -> lift $ print $ getT i tr

fromList xs = fl n xs
    where n = length xs

fl n [x] = Leaf x
fl n xs = Tree n 0 leftT rightT
    where n' = n `div` 2
          (xsL, xsR) = splitAt n' xs
          leftT = fl n' xsL
          rightT = fl (n-n') xsR

addT :: Num a =>  Int -> Int -> a -> SegTree a -> SegTree a
addT _ _ x (Leaf v) = Leaf (v+x)
addT s t x tr
  | n < s = tr { right = addT (s-n) (t-n) x (right tr)}
  | n >= t = tr { left = addT s t x (left tr)}
  | t-s+1 == size tr = tr { toBePlused = toBePlused tr + x }
  | otherwise = tr { left = addT s n x (left tr)
                   , right = addT 1 (t-n) x (right tr)
                   }
    where n = size tr `div` 2

getT :: Num a => Int -> SegTree a -> a
getT _ (Leaf v) = v
getT i tr
  |  n < i = toBePlused tr + getT (i-n) (right tr)
  | n >= i = toBePlused tr + getT i (left tr)
  where n = size tr `div` 2

calcTree :: Num a => SegTree a -> Int -> SegTree a
calcTree = ct 0
ct :: Num a => a -> SegTree a -> Int -> SegTree a
ct acc (Leaf v) _ = Leaf (v+acc)
ct acc tr i
  | n < i = tr { toBePlused = 0
               , left = lt { toBePlused = toBePlused lt + toBePlused tr }
               , right = ct (acc + toBePlused tr) rt (i-n) }
  | n >= i = tr { toBePlused = 0
                , left = ct (acc + toBePlused tr) lt i
                , right = rt {toBePlused = toBePlused lt + toBePlused tr } }
    where n = size tr `div` 2
          lt = left tr
          rt = right tr

