import Control.Monad
import Data.List
import Data.Monoid
import Data.IORef

unwrap [x] = x

initlist :: Int -> [Integer]
initlist n
    | (n == 0) = [0]
    | otherwise = 0 : (initlist (n - 1))

data Tree a = Leaf !Int !a | Node !Int !Int !a !(Tree a) !(Tree a)

buildtree :: Monoid a => [a] -> Int -> Int -> Tree a
buildtree xs l r 
    | ((l + 1) == r) = Leaf l (unwrap xs)
    | otherwise = Node l r mempty (buildtree ys l m) (buildtree zs m r)
    where
        m = (l + r) `div` 2
        (ys,zs) = Data.List.splitAt (m - l) xs

get :: Monoid a => Tree a -> Int -> Int -> a
get (Leaf i x) a b
    | (a <= i && i < b) = x 
    | otherwise = mempty
get (Node l r x xt yt) a b 
    | (b <= l || r <= a) = mempty
    | (a <= l && r <= b) = x
    | otherwise = get xt a b `mappend` get yt a b

val :: Monoid a => Tree a -> a
val (Leaf i x) = x
val (Node l r x xt yt) = x

update :: Monoid a => Tree a -> Int -> a -> Tree a
update (Leaf i x) j k = (Leaf i (x `mappend` k))
update (Node l r x xt yt) i k = 
    if (i < ((l + r) `div` 2)) then
        let nt = update xt i k
        in Node l r ((val nt) `mappend` (val yt)) nt yt
    else
        let nt = update yt i k
        in Node l r ((val xt) `mappend` (val nt)) xt nt

main = do
    [n,q] <- fmap(map read . words) getLine
    let xs = replicate n (mempty :: Sum Int)
    t <- newIORef (buildtree xs 0 n)
    replicateM_ q $ do
        [com,x,y] <- fmap(map read . words) getLine
        rt <- readIORef t
        if (com == 0) then do
            writeIORef t (update rt (x - 1) (Sum y))
        else do
            print $ getSum (get rt (x - 1) y)       

