#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int M = 35;
long long frac[M];
void init() {
  frac[0] = 1;
  for (int i = 1; i < M; i++) {
    frac[i] = frac[i - 1] * i;
  }
}
long long a[M], b[M];
void ICantor(int n, long long x) {
  vector<int> vec;
  for (int i = 1; i <= n; i++) vec.push_back(a[i]);
  for (int i = 1; i <= n; i++) {
    int t = x / frac[n - i];
    x %= frac[n - i];
    b[i] = vec[t];
    vec.erase(vec.begin() + t);
  }
}
long long cal1(long long l, long long r) {
  return r * (r + 1) / 2 - l * (l - 1) / 2;
}
long long cal2(int l, int r) {
  long long ret = 0;
  for (int i = l; i <= r; i++) ret = ret + b[i];
  return ret;
}
int main() {
  init();
  int n, q;
  scanf("%d%d", &n, &q);
  long long nw = 0;
  if (n > 15) {
    for (int i = 1; i <= 15; i++) a[i] = b[i] = (n - 15) + i;
    while (q--) {
      int op;
      scanf("%d", &op);
      if (op == 1) {
        int l, r;
        scanf("%d%d", &l, &r);
        long long ans = 0;
        if (l <= n - 15) ans += cal1(l, min(r, n - 15));
        if (r > n - 15) ans += cal2(max(1, l - (n - 15)), r - (n - 15));
        printf("%lld\n", ans);
      } else {
        int x;
        scanf("%d", &x);
        nw += x;
        ICantor(15, nw);
      }
    }
  } else {
    for (int i = 1; i <= n; i++) a[i] = b[i] = i;
    while (q--) {
      int op;
      scanf("%d", &op);
      if (op == 1) {
        int l, r;
        scanf("%d%d", &l, &r);
        long long ans = cal2(l, r);
        printf("%lld\n", ans);
      } else {
        int x;
        scanf("%d", &x);
        nw += x;
        ICantor(n, nw);
      }
    }
  }
  return 0;
}
