#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long sum, n, q;
long long a[16];
long long P[16];
long long fac[16];
bool vis[16];
void get(long long sum) {
  long long res = 0;
  for (long long i = 1; i < n; i++) res = (res + a[i]) * (n - i);
  for (long long i = 1; i <= 15; i++) {
    a[i] = sum / fac[15 - i];
    sum %= fac[15 - i];
  }
  memset(vis, 0, sizeof(vis));
  for (long long i = 1; i <= 15; i++) {
    long long cnt = 0;
    for (long long j = 1; j <= 15; j++) {
      if (!vis[j]) cnt++;
      if (cnt == a[i] + 1) {
        P[i] = j;
        vis[j] = 1;
        break;
      }
    }
  }
}
signed main() {
  n = read();
  q = read();
  fac[0] = 1;
  for (long long i = 1; i <= 15; i++) fac[i] = fac[i - 1] * i;
  while (q--) {
    long long opt;
    opt = read();
    if (opt == 1) {
      long long l, r;
      l = read();
      r = read();
      long long ans = 0;
      get(sum);
      if (r > n - 15) {
        if (l > n - 15) {
          for (long long i = l - n + 15; i <= r - n + 15; i++) ans += P[i];
          ans += (r - l + 1) * (n - 15);
        } else {
          ans += (l + n - 15) * (n - 14 - l) / 2;
          for (long long i = 1; i <= r - n + 15; i++) ans += P[i];
          ans += (r - n + 15) * (n - 15);
        }
      } else
        ans = (l + r) * (r - l + 1) / 2;
      printf("%lld\n", ans);
    }
    if (opt == 2) {
      long long x;
      x = read();
      sum += x;
    }
  }
  return 0;
}
