#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  each(x,vec) is >> x;
  return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
  rep(i,vec.size()) {
    if (i) os << " ";
    os << vec[i];
  }
  return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
  rep(i,vec.size()) {
    if (i) os << endl;
    os << vec[i];
  }
  return os;
}

class Segtree {
  struct Node {
    Node *lch, *rch;
    long long sum;
    Node() : sum(0), lch(nullptr), rch(nullptr) {}
    ~Node() {
      // if (lch != nullptr) delete lch;
      // if (rch != nullptr) delete rch;
    }
    void add(ll x, ll val, ll lb, ll ub) {
      if (x >= ub) return;
      Node* node = this;
      while (ub - lb > 1) {
        node->sum += val;
        ll mid = (lb + ub) / 2;
        if (x < mid) {
          if (node->lch == nullptr) node->lch = new Node();
          node = node->lch;
          ub = mid;
        }
        else {
          if (node->rch == nullptr) node->rch = new Node();
          node = node->rch;
          lb = mid;
        }
      }
      node->sum += val;
    }
    long long find(ll r, ll lb, ll ub) {
      long long res = 0;
      Node* node = this;
      while (node != nullptr) {
        ll mid = (lb + ub) / 2;
        if (ub <= r) {
          res += node->sum;
          break;
        }
        else if (r < mid) {
          ub = mid;
          node = node->lch;
        }
        else {
          if (node->lch != nullptr) res += node->lch->sum;
          lb = mid;
          node = node->rch;
        }
      }
      return res;
    }
  };
  Node *root;
  const ll n;
public:
  Segtree() : Segtree(0) {}
  Segtree(ll n) : root(new Node()), n(n) {}
  void add(ll x, ll val) {
    if (x < 0 || x >= n) return;
    root->add(x, val, 0, n);
  }
  long long find(ll r) {
    if (r == 0) return 0;
    return root->find(min(n, r), 0, n);
  }
  ~Segtree() { delete root; }
};

struct Trie {
  ll keta, n;
  Trie *lch, *rch;
  Segtree seg;
  Trie() : lch(nullptr), rch(nullptr), n(0), seg() {}
  Trie(ll keta, ll n) : lch(nullptr), rch(nullptr), keta(keta), n(n), seg(n) {}
  Trie* make_child() {
    assert(keta > 0);
    return new Trie(keta-1, n);
  }
  // x, y に +k
  void add(ll x, ll y, ll k) {
    Trie* t = this;
    while (t->keta > 0) {
      t->seg.add(y, k);
      ll mid = 1LL<<(t->keta-1);
      if (x >= mid) {
        x -= mid;
        if (t->rch == nullptr) t->rch = t->make_child();
        t = t->rch;
      }
      else {
        if (t->lch == nullptr) t->lch = t->make_child();
        t = t->lch;
      }
    }
    t->seg.add(y, k);
  }
  // [0, r) 中, xでxorしてk未満
  long long find(ll r, ll x, ll k) {
    long long res = 0;
    Trie* t = this;
    while (t != nullptr) {
      if (k >= (1LL<<t->keta)) {
        res += t->seg.find(r);
        break;
      }
      if (keta == 0 || k == 0) break;
      ll mid = 1LL<<(t->keta-1);
      Trie *left = t->lch, *right = t->rch;
      if (x>>(t->keta-1) & 1) swap(left, right);
      if (k >= mid) {
        if (left != nullptr) res += left->seg.find(r);
        k -= mid;
        t = right;
      }
      else {
        t = left;
      }
    }
    return res;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, Q; cin >> n >> Q;
  Trie trie(30, 1);
  rep(q, Q) {
    ll t, x, y; cin >> t >> x >> y; --x;
    if (t == 0) trie.add(x, 0, y);
    else cout << trie.find(1, 0, y) - trie.find(1, 0, x) << endl;
  }
}



Measured memory_bytes: 14188