#include <bits/stdc++.h>
using namespace std;
vector<long long> fact(16);
void solve() {
  long long n, q, cnt(0);
  cin >> n >> q;
  long long len = min(n, 15ll);
  vector<long long> v(len), a(n);
  vector<bool> vis;
  iota(a.begin(), a.end(), n - len + 1);
  iota(v.begin(), v.end(), n - len + 1);
  function<long long(long long)> kmax = [&](long long k) {
    priority_queue<pair<long long, long long>> q;
    long long sz(0);
    for (long long i = 0; i < len; i++) {
      if (vis[i]) continue;
      if (sz < k)
        q.push({a[i], i}), sz++;
      else
        q.push({a[i], i}), q.pop();
    }
    return q.top().second;
  };
  function<void(long long)> update = [&](long long cnt) {
    vis.assign(len, 0);
    for (long long i = len - 1; i >= 0; i--) {
      long long q = cnt / fact[i];
      cnt = cnt % fact[i];
      long long idx = kmax(q + 1);
      v[len - i - 1] = a[idx];
      vis[idx] = 1;
    }
  };
  while (q--) {
    long long t;
    cin >> t;
    if (t - 1) {
      long long x;
      cin >> x;
      cnt += x;
      update(cnt);
    } else {
      long long l, r;
      cin >> l >> r;
      long long s1(0), s2(0);
      if (n <= 15) {
        l--, r--;
        for (long long i = l; i <= r; i++) s1 += v[i];
      } else {
        long long s = max(0ll, len - n + l - 1);
        long long e = r + len - n;
        r = min(a[0] - 1, r);
        l--;
        if (l < r)
          s1 = ((((long long)r * (long long)(r + 1)) >> 1ll) -
                (((long long)l * (long long)(l + 1)) >> 1ll));
        for (; s < e; s++) s2 += v[s];
      }
      cout << s1 + s2 << "\n";
    }
  }
}
signed main() {
  fact[0] = 1;
  for (long long i = 1; i < 16; i++) fact[i] = fact[i - 1] * i;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t(1);
  for (long long i = 1; i <= t; solve(), i++)
    ;
  return 0;
}
