#include <bits/stdc++.h>
using namespace std;
vector<long long> ithPermutation(int n, long long i) {
  long long j, k = 0;
  vector<long long> fact(n), perm(n);
  fact[k] = 1;
  while (++k < n) fact[k] = fact[k - 1] * k;
  for (k = 0; k < n; ++k) {
    perm[k] = i / fact[n - 1 - k];
    i = i % fact[n - 1 - k];
  }
  for (k = n - 1; k > 0; --k)
    for (j = k - 1; j >= 0; --j)
      if (perm[j] <= perm[k]) perm[k]++;
  return perm;
}
int main() {
  int n, q;
  cin >> n >> q;
  long long s = 0;
  for (int i = 0; i < q; i++) {
    int a;
    cin >> a;
    if (a == 1) {
      long long l, r;
      cin >> l >> r;
      r--;
      l--;
      long long x = 0;
      if (n <= 15) {
        vector<long long> u = ithPermutation(n, s);
        for (int j = l; j <= r; j++) {
          x += u[j] + 1;
        }
      } else {
        if (l < n - 15) {
          long long r1 = min(r, (long long)(n - 16));
          x = ((r1 - l + 1) * (r1 + l + 2)) / 2;
          vector<long long> u = ithPermutation(15, s);
          for (int j = n - 15; j <= r; j++) {
            x += u[j - n + 15] + n - 14;
          }
        } else {
          vector<long long> u = ithPermutation(15, s);
          for (int j = l; j <= r; j++) {
            x += u[j - n + 15] + n - 14;
          }
        }
      }
      cout << x << endl;
    } else {
      long long b;
      cin >> b;
      s += b;
    }
  }
}
