#include <bits/stdc++.h>
using namespace std;
long long fact[16];
long long topperm = 0;
vector<int> orgperm;
vector<int> perm;
void xthperm(long long x) {
  vector<int> temp = orgperm;
  topperm += x;
  x = topperm;
  perm.clear();
  int curfact = temp.size() - 1;
  while (curfact >= 0) {
    int ind = x / fact[curfact];
    x %= fact[curfact];
    curfact--;
    perm.push_back(temp[ind]);
    temp.erase(temp.begin() + ind);
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cerr.tie(nullptr);
  fact[0] = 1;
  for (int i = 1; i <= 15; i++) fact[i] = i * fact[i - 1];
  int n, q;
  cin >> n >> q;
  if (n > 15) {
    for (int i = n - 15 + 1; i <= n; i++) orgperm.push_back(i);
    perm = orgperm;
    while (q--) {
      int qq;
      cin >> qq;
      if (qq == 1) {
        long long l, r;
        cin >> l >> r;
        long long sum = 0;
        if (l < n - 15 + 1) {
          long long sag;
          if (r >= n - 15 + 1)
            sag = n - 15;
          else
            sag = r;
          sum += (l + sag) * (sag - l + 1) / 2;
        }
        if (r >= n - 15 + 1) {
          long long sol;
          if (l < n - 15 + 1)
            sol = n - 15 + 1;
          else
            sol = l;
          for (int i = sol; i <= r; i++) {
            sum += perm[i - (n - 15 + 1)];
          }
        }
        cout << sum << '\n';
      } else {
        long long x;
        cin >> x;
        xthperm(x);
      }
    }
  } else {
    for (int i = 1; i <= n; i++) orgperm.push_back(i);
    perm = orgperm;
    while (q--) {
      int qq;
      cin >> qq;
      if (qq == 1) {
        int l, r;
        cin >> l >> r;
        int sum = 0;
        for (int i = l; i <= r; i++) sum += perm[i - 1];
        cout << sum << '\n';
      } else {
        long long x;
        cin >> x;
        xthperm(x);
      }
    }
  }
}
