#include "bits/stdc++.h"

using namespace std;

using i64 = long long;


// merge/split ベースの赤黒木(葉木)
struct RedBlackTree{
    struct Node{
        /*
        uint64_t x;
        short cnt;
        int siz, cnt_sum;
        bool red;
        Node* c[2];
        Node(Node* nil = nullptr) : x(0), cnt(0), siz(0), cnt_sum(0), red(false){
            c[0] = nil;
            c[1] = nil;
        }
         */
        int sum, siz, rank;
        bool red;
        Node* l;
        Node* r;
        Node(int val, bool red, bool leaf, Node* l = nullptr, Node* r = nullptr) : sum(val), siz(leaf), rank(0), red(red), l(l), r(r){}
    };

    Node* nil;
    RedBlackTree(){
        nil = new Node(0, false, false);
        nil->l = nil;
        nil->r = nil;
    }

    void update(Node* p){
        if(p == nil)
            return;
        p->siz = p->l->siz + p->r->siz;
        if(p->l != nil || p->r != nil)
            p->sum = p->l->sum + p->r->sum;
        p->rank = p->l->rank + !p->l->red;
        assert(p->rank == p->r->rank + !p->r->red);
        // p->cnt_sum = p->c[0]->cnt_sum + p->c[1]->cnt_sum + p->cnt;
    }

    Node* make(int val){
        Node* node = new Node(val, false, true, nil, nil);
        node->rank = 1;
        return node;
    }

    Node* mergeSub(Node* a, Node* b){
        assert(a != nil && b != nil);
        if(a->rank < b->rank){
            Node* c = mergeSub(a, b->l);
            if(!b->red && c->red && c->l->red){
                if(!b->r->red){
                    b->l = c->l;
                    c->l = c->r;
                    c->r = b->r;
                    b->r = c;
                    update(c);
                    update(b);
                    return b;
                }
                else{
                    b->l = c;
                    b->red ^= 1;
                    b->l->red ^= 1;
                    b->r->red ^= 1;
                    update(b);
                    return b;
                }
            }
            b->l = c;
            update(b);
            return b;
        }
        else if(a->rank > b->rank){
            Node* c = mergeSub(a->r, b);
            if(!a->red && c->red && c->r->red){
                if(!a->l->red){
                    a->r = c->r;
                    c->r = c->l;
                    c->l = a->l;
                    a->l = c;
                    update(c);
                    update(a);
                    return a;
                }
                else{
                    a->r = c;
                    a->red ^= 1;
                    a->l->red ^= 1;
                    a->r->red ^= 1;
                    update(a);
                    return a;
                }
            }
            a->r = c;
            update(a);
            return a;
        }
        else{
            a->red = false;
            b->red = false;
            Node* node = new Node(0, true, false, a, b);
            update(node);
            return node;
        }
    }

    Node* merge(Node* a, Node* b){
        if(a == nil)
            return b;
        if(b == nil)
            return a;
        Node* c = mergeSub(a, b);
        c->red = false;
        return c;
    }

    pair<Node*, Node*> split(Node* a, int k){
        if(k == 0)
            return make_pair(nil, a);
        if(k == a->siz)
            return make_pair(a, nil);
        Node* l = a->l;
        Node* r = a->r;
        delete(a);
        if(k < l->siz){
            auto res = split(l, k);
            return make_pair(res.first, merge(res.second, r));
        }
        else if(k > a->l->siz){
            auto res = split(r, k - l->siz);
            return make_pair(merge(l, res.first), res.second);
        }
        else{
            return make_pair(l, r);
        }
    }

    pair<int, Node*> range_get(Node* p, int l, int r){
        auto res = split(p, r);
        auto res2 = split(res.first, l);
        int val = res2.second->sum;
        Node* rn = merge(res2.second, res.second);
        Node* mn = merge(res2.first, rn);
        return make_pair(val, mn);
    }

    Node* access(Node* p, int k){
        int t = 0;
        while(p->l != nil || p->r != nil){
            ++t;
            assert(p->l != nil && p->r != nil);
            if(p->l->siz <= k){
                k -= p->l->siz;
                p = p->r;
            }
            else{
                p = p->l;
            }
        }
        return p;
    }

    Node* add(Node* p, int k, int val){
        int t = 0;
        stack<Node*> st;
        while(p->l != nil || p->r != nil){
            ++t;
            st.push(p);
            assert(p->l != nil && p->r != nil);
            if(p->l->siz <= k){
                k -= p->l->siz;
                p = p->r;
            }
            else{
                p = p->l;
            }
        }
        p->sum += val;
        while(!st.empty()){
            update(st.top());
            st.pop();
        }
        return p;
    }

};


signed main(){
    int n, q;
    cin >> n >> q;
    RedBlackTree rb;
    auto root = rb.nil;
    for(int i = 0; i < n; ++i){
        root = rb.merge(root, rb.make(0));
    }
    for(int i = 0; i < q; ++i){
        int com, x, y;
        cin >> com >> x >> y;
        --x;
        if(com == 0){
            rb.add(root, x, y);
        }
        else{
            auto res = rb.range_get(root, x, y);
            cout << res.first << endl;
            root = res.second;
        }
    }
}




Measured memory_bytes: 12448