#include <bits/stdc++.h>
using namespace std;
int n, m, q, op, x, y, c[16];
long long sum[200001], jc[16] = {1}, now;
inline int lowbit(int x) { return x & (-x); }
void update(int x, int v) {
  for (; x <= m; x += lowbit(x)) c[x] += v;
}
int Find(int x) {
  int now = 0;
  for (register int i = 1 << 4; i; i >>= 1)
    if (now + i <= m && c[now + i] < x) x -= c[now + i], now += i;
  return now + 1;
}
int main() {
  scanf("%d%d", &n, &q);
  m = min(n, 15);
  for (register int i = 1; i <= 15; ++i) jc[i] = jc[i - 1] * i;
  for (register int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + i;
  if (n <= 15) {
    while (q--) {
      scanf("%d", &op);
      if (op == 2) {
        scanf("%d", &x);
        now += x;
      } else {
        scanf("%d%d", &x, &y);
        long long ans = 0, tmp = now;
        for (register int i = 1; i <= m; ++i) update(i, 1);
        for (register int i = 1; i <= m; ++i) {
          int z = tmp / jc[m - i] + 1;
          tmp %= jc[m - i];
          int pos = Find(z);
          if (i >= x && i <= y) ans += pos;
          update(pos, -1);
        }
        printf("%lld\n", ans);
      }
    }
    return 0;
  }
  while (q--) {
    scanf("%d", &op);
    if (op == 2) {
      scanf("%d", &x);
      now += x;
    } else {
      scanf("%d%d", &x, &y);
      long long ans = 0;
      if (y <= n - 15) {
        printf("%lld\n", sum[y] - sum[x - 1]);
        continue;
      }
      if (x <= n - 15) {
        ans += sum[n - 15] - sum[x - 1];
        x = n - 14;
      }
      long long tmp = now;
      for (register int i = 1; i <= m; ++i) update(i, 1);
      for (register int i = 1; i <= m; ++i) {
        int z = tmp / jc[m - i] + 1;
        tmp %= jc[m - i];
        int pos = Find(z);
        if (i >= x - n + 15 && i <= y - n + 15) ans += pos;
        update(pos, -1);
      }
      printf("%lld\n", ans + (long long)(n - 15) * (y - x + 1));
    }
  }
  return 0;
}
