#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
const long long N = 1e7 + 10;
long long findFirstNumIndex(long long& k, long long n) {
  if (n == 1) return 0;
  n--;
  long long first_num_index;
  long long n_partial_fact = n;
  while (k >= n_partial_fact && n > 1) {
    n_partial_fact = n_partial_fact * (n - 1);
    n--;
  }
  first_num_index = k / n_partial_fact;
  k = k % n_partial_fact;
  return first_num_index;
}
vector<long long> findKthPermutation(long long n, long long k) {
  vector<long long> ans;
  set<long long> s;
  for (long long i = 1; i <= n; i++) s.insert(i);
  set<long long>::iterator itr;
  itr = s.begin();
  k = k - 1;
  for (long long i = 0; i < n; i++) {
    long long index = findFirstNumIndex(k, n - i);
    advance(itr, index);
    ans.push_back(*itr);
    s.erase(itr);
    itr = s.begin();
  }
  return ans;
}
int32_t main() {
  long long n, q;
  cin >> n >> q;
  long long curr = 1;
  vector<long long> pref(n + 1);
  for (long long i = 1; i <= n; i++) {
    pref[i] = pref[i - 1] + i;
  }
  while (q--) {
    long long type;
    cin >> type;
    if (type == 1) {
      long long l, r;
      cin >> l >> r;
      if (n <= 15) {
        vector<long long> temp = findKthPermutation(n, curr);
        l--;
        r--;
        long long ans = 0;
        for (long long i = l; i <= r; i++) {
          ans += temp[i];
        }
        cout << ans << endl;
      } else {
        vector<long long> temp = findKthPermutation(15, curr);
        long long end = n - 15;
        for (long long j = 0; j < 15; j++) {
          temp[j] += end;
        }
        long long ans = 0;
        if (r <= end) {
          ans = pref[r] - pref[l - 1];
        } else if (l > end) {
          for (long long j = l; j <= r; j++) {
            ans += temp[j - end - 1];
          }
        } else {
          ans += pref[end] - pref[l - 1];
          for (long long i = end + 1; i <= r; i++) {
            ans += temp[i - end - 1];
          }
        }
        cout << ans << endl;
      }
    } else {
      long long x;
      cin >> x;
      curr += x;
    }
  }
}
