#include <bits/stdc++.h>
using namespace std;
const int Max = 2e5 + 5;
const int Mod = 998244353;
const int inf = 0x3f3f3f3f;
long long sum[Max], p[Max];
long long F[20];
void init() {
  F[0] = 1;
  for (int i = 1; i <= 15; i++) F[i] = F[i - 1] * i;
}
long long ConTor(int n, int Mid) {
  long long X = 1;
  for (int i = Mid + 1; i < n; i++) {
    long long temp = 0;
    for (int j = i + 1; j <= n; j++) {
      if (p[j] > p[i]) continue;
      temp++;
    }
    X += temp * F[n - i];
  }
  return X;
}
bool vis[Max];
void invConTor(int n, int Mid, long long X) {
  X--;
  long long rest = X;
  vector<int> vec;
  for (int i = Mid + 1; i <= n; i++) {
    vis[i] = 0;
    vec.push_back(i);
  }
  for (int i = Mid + 1; i <= n; i++) {
    int num = rest / F[n - i];
    rest = rest % F[n - i];
    p[i] = vec[num];
    vec.erase(vec.begin() + num);
  }
}
int main(void) {
  init();
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; i++) p[i] = i;
  int Mid = max(0, n - 15);
  for (int i = 1; i <= Mid; i++) sum[i] = sum[i - 1] + p[i];
  while (q--) {
    int op;
    cin >> op;
    if (op == 1) {
      int l, r;
      cin >> l >> r;
      if (r <= Mid)
        cout << sum[r] - sum[l - 1] << '\n';
      else if (l <= Mid) {
        long long temp = sum[Mid] - sum[l - 1];
        for (int i = Mid + 1; i <= r; i++) temp += p[i];
        cout << temp << '\n';
      } else {
        long long temp = 0;
        for (int i = l; i <= r; i++) temp += p[i];
        cout << temp << '\n';
      }
    } else {
      long long x;
      cin >> x;
      long long now = ConTor(n, Mid);
      now += x;
      invConTor(n, Mid, now);
    }
  }
}
