#include <bits/stdc++.h>
using namespace std;
long long FAC[20];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  FAC[0] = 1;
  for (long long i = 1; i <= 15; i++) FAC[i] = i * FAC[i - 1];
  long long n, q;
  cin >> n >> q;
  if (n > 15) {
    long long cnt = 0;
    for (long long i = 0; i < q; i++) {
      long long k, l, x;
      cin >> k;
      if (k == 1) {
        cin >> l >> x;
        long long p = cnt;
        vector<long long> v;
        vector<long long> a;
        for (long long i = 1; i <= 15; i++) v.push_back(i);
        for (long long i = 15; i >= 1; i--) {
          long long r = p % FAC[i - 1];
          long long t = p / FAC[i - 1];
          p = r;
          a.push_back(v[t]);
          v.erase(v.begin() + t);
        }
        long long ans = 0;
        if (l > n - 15) {
          for (long long i = l - n + 14; i < x - n + 15; i++) ans += a[i];
          ans += (n - 15) * (x - l + 1);
        } else if (x <= n - 15)
          ans = (l + x) * (x - l + 1) / 2;
        else {
          ans += (l + n - 15) * (n - 14 - l) / 2;
          for (long long i = 0; i < x - n + 15; i++) ans += (n - 15) + a[i];
        }
        cout << ans << endl;
      } else {
        cin >> x;
        cnt += x;
      }
    }
  } else {
    long long cnt = 0;
    for (long long i = 0; i < q; i++) {
      long long k, l, x;
      cin >> k;
      if (k == 1) {
        cin >> l >> x;
        long long p = cnt;
        vector<long long> v;
        vector<long long> a;
        for (long long i = 1; i <= n; i++) v.push_back(i);
        for (long long i = n; i >= 1; i--) {
          long long r = p % FAC[i - 1];
          long long t = p / FAC[i - 1];
          p = r;
          a.push_back(v[t]);
          v.erase(v.begin() + t);
        }
        long long ans = 0;
        for (long long i = l - 1; i < x; i++) ans += a[i];
        cout << ans << endl;
      } else {
        cin >> x;
        cnt += x;
      }
    }
  }
  return 0;
}
