#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
template <typename T>
using vec = vector<T>;
template <typename T>
using Prior = priority_queue<T>;
template <typename T>
using prior = priority_queue<T, vec<T>, greater<T>>;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9 + 7;
const double PI = 3.14159265358;
const double EPS = 1e-8;
const int xx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int yy[8] = {1, 0, -1, 0, 1, -1, -1, 1};
unsigned seed = chrono::steady_clock::now().time_since_epoch().count();
mt19937 rng(seed);
uniform_int_distribution<int> dist(1, 1e6);
template <typename T>
void dbg(T x) {
  cerr << x << '\n';
}
template <typename T, typename... A>
void dbg(T x, A... y) {
  cerr << x << ", ";
  dbg(y...);
}
template <typename T>
void amax(T &a, T b) {
  if (a < b) a = b;
}
template <typename T>
void amin(T &a, T b) {
  if (a > b) a = b;
}
template <typename T>
bool INR(T a, T b, T c) {
  return b <= a && a <= c;
}
void pmod(ll &a, ll b) { a = (a + b) % MOD; }
void mmod(ll &a, ll b) { a = (a - b + MOD) % MOD; }
void tmod(ll &a, ll b) { a = (a * b) % MOD; }
void UNI(vec<int> &v) {
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
}
int getint() {
  int ret;
  cin >> ret;
  return ret;
}
ll getll() {
  ll ret;
  cin >> ret;
  return ret;
}
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll POW(ll a, ll b) {
  ll res = 1;
  do {
    if (b % 2) tmod(res, a);
    tmod(a, a);
  } while (b >>= 1);
  return res;
}
const int MXN = 500;
const int N = MXN + 10;
void solve() {
  ll n, m;
  cin >> n >> m;
  int k = min(n, 16LL);
  vec<int> v;
  for (int i = 1; i <= (k); ++i) v.emplace_back(n - k + i);
  vec<ll> cnt(k), fact(k, 1);
  for (int i = (k - 1) - 1; i >= 0; --i) fact[i] = fact[i + 1] * (k - i);
  while (m--) {
    int op = getint();
    if (op == 1) {
      ll l, r;
      cin >> l >> r;
      ll ans = max(0LL, (min(n - k, r) + l) * (min(n - k, r) - l + 1) / 2);
      for (int i = (max(0LL, l - (n - k + 1))); i <= (r - (n - k) - 1); ++i)
        ans += v[i];
      cout << ans << '\n';
    } else {
      ll x = getll();
      for (int i = 0; i < (k - 1); ++i) {
        while (x >= fact[i + 1]) {
          ++cnt[i];
          x -= fact[i + 1];
          for (int j = i; j; --j) {
            if (cnt[j] == (k - j)) {
              ++cnt[j - 1];
              cnt[j] = 0;
            } else {
              break;
            }
          }
        }
      }
      set<int> st;
      for (int i = 1; i <= (k); ++i) st.insert(n - k + i);
      for (int i = 0; i < (k); ++i) {
        auto it = st.begin();
        for (int j = 0; j < (cnt[i]); ++j) it = next(it);
        v[i] = *it;
        st.erase(*it);
      }
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T = 1;
  while (T--) {
    solve();
  }
}
