#include <bits/stdc++.h>
using namespace std;
template <typename... Ts>
void do_nothing(Ts &&...vals) {}
constexpr long long MOD = 1000000007;
constexpr int INF = 0x7f7f7f7f;
constexpr double EPS = 1e-8;
long long fastPow(long long num, long long exp) {
  if (exp == 0) return 1;
  if (exp == 1)
    return num;
  else {
    long long half = fastPow(num, exp / 2);
    if (exp % 2 == 1) {
      return half * half * num;
    } else {
      return half * half;
    }
  }
}
int main(int argn, char **argv) {
  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);
  int n, q;
  cin >> n >> q;
  vector<long long> prefix(n + 1);
  prefix[0] = 0;
  for (int(i) = (1); (i) <= (n); (i)++) {
    prefix[i] = prefix[i - 1] + i;
  }
  long long advance = 0;
  vector<long long> modNum(20, (long long)1);
  int maxChanged = 2;
  for (; maxChanged <= n; maxChanged++) {
    modNum[maxChanged] = modNum[maxChanged - 1] * (maxChanged);
    if (modNum[maxChanged] > 2e10) break;
  }
  for (int(i) = (0); (i) <= ((q)-1); (i)++) {
    int kind;
    cin >> kind;
    if (kind == 1) {
      int l, r;
      cin >> l >> r;
      vector<long long> num(maxChanged);
      vector<bool> used(maxChanged, false);
      for (int(i) = (0); (i) <= ((maxChanged)-1); (i)++) {
        num[i] = n + 1 + i - maxChanged;
      }
      for (int j = maxChanged; j >= 1; j--) {
        long long newOrder = (advance % modNum[j]) / modNum[j - 1];
        int crtIndex = -1;
        for (int(s) = (0); (s) <= ((maxChanged)-1); (s)++) {
          if (!used[s]) {
            crtIndex++;
            if (crtIndex == newOrder) {
              used[s] = true;
              prefix[n + 1 - j] = prefix[n - j] + num[s];
              break;
            }
          }
        }
      }
      cout << prefix[r] - prefix[l - 1] << endl;
    } else {
      int x;
      cin >> x;
      advance += x;
    }
  }
}
