#include <bits/stdc++.h>
using namespace std;
vector<long long> genperm(long long x, set<long long> p,
                          vector<long long> &fac) {
  int n = p.size();
  vector<long long> ans;
  for (int i = 0; i < n && x > 0; ++i) {
    if (x >= fac[n - i - 1]) {
      long long need = (x + fac[n - i - 1] - 1) / fac[n - i - 1];
      int j = 0;
      auto it = p.begin();
      while (j < need) ++j, ++it;
      it--, j--;
      ans.push_back(*it);
      p.erase(it);
      x -= fac[n - i - 1] * j;
    } else {
      ans.push_back(*p.begin());
      p.erase(p.begin());
    }
  }
  while (!p.empty()) {
    ans.push_back(*p.begin());
    p.erase(p.begin());
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, q;
  cin >> n >> q;
  vector<long long> fac(16, 1);
  for (long long i = 1; i <= 15; ++i) fac[i] = fac[i - 1] * i;
  long long x = 0;
  set<long long> p;
  for (long long i = n; i && i > n - 15; --i) p.insert(i);
  vector<long long> curperm = genperm(1, p, fac);
  while (q--) {
    int qi;
    cin >> qi;
    if (qi == 2) {
      long long xi;
      cin >> xi;
      x += xi;
      curperm = genperm(x + 1, p, fac);
    } else {
      long long l, r, sum = 0;
      cin >> l >> r;
      if (n <= 15)
        for (int i = l - 1; i < r; ++i) sum += curperm[i];
      else {
        long long mn = min(r, (long long)n - 15);
        if (l <= n - 15) {
          sum += (long long)(mn * (mn + 1) / 2) - (long long)(l * (l - 1) / 2);
          if (r > n - 15)
            for (int i = 0, j = n - 14; j <= r; ++j, ++i) sum += curperm[i];
        } else
          for (int i = l - (n - 14); i <= r - (n - 14); ++i) sum += curperm[i];
      }
      cout << sum << endl;
    }
  }
  return 0;
}
