#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long MAX = 2e5 + 1;
void Solve() {
  long long n, q, p = 14;
  cin >> n >> q;
  vector<long long> a(n), prefix(n);
  iota(a.begin(), a.end(), 1);
  for (long long i = 0; i < n; i++) {
    prefix[i] = (i ? prefix[i - 1] + a[i] : a[i]);
  }
  function<void(vector<long long>)> fixPrefix =
      [&](vector<long long> permutation) {
        long long x = permutation.size();
        for (long long i = 0; i < x; i++) {
          a[n - x + i] = permutation[i];
        }
        for (long long i = n - x; i < n; i++) {
          prefix[i] = (i ? prefix[i - 1] + a[i] : a[i]);
        }
      };
  function<void(long long, long long, long long)> kThPermutation =
      [&](long long n, long long k, long long start) {
        vector<long long> fact(p + 1, 1);
        for (long long i = 1; i <= p; i++) {
          fact[i] = i * fact[i - 1];
        }
        vector<long long> permutation(n, start);
        for (long long i = 0; i < n; i++) {
          permutation[i] += k / fact[n - 1 - i];
          k %= fact[n - 1 - i];
        }
        for (long long i = n - 1; i >= 0; i--) {
          for (long long j = i - 1; j >= 0; j--) {
            if (permutation[j] <= permutation[i]) {
              permutation[i]++;
            }
          }
        }
        fixPrefix(permutation);
      };
  long long k = 0;
  while (q--) {
    long long type;
    cin >> type;
    if (type == 1) {
      long long l, r;
      cin >> l >> r;
      l--, r--;
      cout << prefix[r] - (l ? prefix[l - 1] : 0) << "\n";
    } else {
      long long x;
      cin >> x;
      k += x;
      kThPermutation(min(n, p), k, max(n - p + 1, 1LL));
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long testcases = 1;
  while (testcases--) {
    Solve();
  }
}
