#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const vector<ll> fac = {1,       1,        2,         6,         24,
                        120,     720,      5040,      40320,     362880,
                        3628800, 39916800, 479001600, 6227020800};
vector<int> kth(vector<int>& R, ll k) {
  vector<int> num = R, ret;
  for (int i = R.size() - 1; ~i; --i) {
    ll x = k / fac[i];
    ret.emplace_back(num[x]);
    num.erase(num.begin() + x);
    k %= fac[i];
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  int num_right = min(n, 14);
  int num_left = n - num_right;
  vector<ll> psum(num_left + 1);
  vector<int> R(num_right);
  iota(psum.begin() + 1, psum.end(), 1);
  iota(R.begin(), R.end(), num_left + 1);
  partial_sum(psum.begin(), psum.end(), psum.begin());
  ll k = 0;
  for (int op, x, l, r; q--;) {
    cin >> op;
    if (op == 1) {
      cin >> l >> r;
      ll ans = 0;
      if (l <= num_left) ans += psum[min(num_left, r)] - psum[l - 1];
      if (r > num_left) {
        auto vt = kth(R, k);
        for (int i = max(0, l - num_left - 1); i < r - num_left; ++i)
          ans += vt[i];
      }
      cout << ans << '\n';
    } else {
      cin >> x;
      k += x;
    }
  }
}
