#include <bits/stdc++.h>
using namespace std;
int n, q;
long long fact[20];
int v[20];
long long sp[200005];
void getpermutation(long long sz, long long k) {
  vector<bool> used(sz + 15, 0);
  for (int i = 1; i <= sz; i++) v[i] = i;
  for (int i = 1; i <= sz; i++) {
    for (int j = 1; j <= sz; j++) {
      if (used[j] == 0) {
        if (k > fact[sz - i]) {
          k -= fact[sz - i];
        } else {
          used[j] = 1;
          v[i] = j;
          break;
        }
      }
    }
  }
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  fact[0] = 1;
  for (int i = 1; i <= 15; i++) {
    fact[i] = 1LL * fact[i - 1] * 1LL * i;
  }
  for (int i = 1; i <= n; i++) sp[i] = sp[i - 1] + 1LL * i;
  if (n <= 15) {
    for (int i = 1; i <= n; i++) v[i] = i;
    long long nrperm = 1;
    for (int i = 1; i <= q; i++) {
      int type;
      cin >> type;
      if (type == 1) {
        int l, r;
        cin >> l >> r;
        int sum = 0;
        for (int i = l; i <= r; i++) {
          sum += v[i];
        }
        cout << sum << '\n';
      } else {
        int x;
        cin >> x;
        nrperm += x;
        getpermutation(n, nrperm);
      }
    }
  } else {
    long long nrperm = 1;
    for (int i = 1; i <= 15; i++) {
      v[i] = i;
    }
    for (int i = 1; i <= q; i++) {
      int type;
      cin >> type;
      if (type == 2) {
        long long x;
        cin >> x;
        nrperm += x;
        getpermutation(15, nrperm);
        for (int j = n - 14; j <= n; j++) {
          sp[j] = sp[j - 1] + 1LL * v[j - (n - 15)] + (n - 15);
        }
      } else {
        int l, r;
        cin >> l >> r;
        cout << sp[r] - sp[l - 1] << '\n';
      }
    }
  }
}
