#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long kkk = 0, x = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') c = getchar(), x = -1;
  while (c >= '0' && c <= '9')
    kkk = (kkk << 3) + (kkk << 1) + (c - '0'), c = getchar();
  return kkk * x;
}
long long n, q, a[200001], p[200001], sum[10], tree[200001], Tree[800001];
void xg(long long zone, long long v) {
  while (zone <= n) {
    tree[zone] += v;
    zone += (zone & -zone);
  }
}
long long cx(long long zone) {
  long long bck = 0;
  while (zone) {
    bck += tree[zone];
    zone -= (zone & -zone);
  }
  return bck;
}
void XG(long long l, long long r, long long zone, long long v, long long bj) {
  if (l == r) {
    Tree[bj] += v;
    return;
  }
  long long mid = (l + r) / 2;
  if (zone <= mid)
    XG(l, mid, zone, v, bj * 2);
  else
    XG(mid + 1, r, zone, v, bj * 2 + 1);
  Tree[bj] = Tree[bj * 2] + Tree[bj * 2 + 1];
}
long long CX(long long l, long long r, long long K, long long bj) {
  if (l == r) return l;
  long long mid = (l + r) / 2;
  if (Tree[bj * 2] >= K)
    return CX(l, mid, K, bj * 2);
  else
    return CX(mid + 1, r, K - Tree[bj * 2], bj * 2 + 1);
}
signed main() {
  n = read(), q = read();
  sum[0] = 1;
  for (long long i = 1; i <= 9; ++i) sum[i] = sum[i - 1] * i;
  for (long long i = 1; i <= n; ++i) a[i] = i, p[i] = 0, xg(i, i);
  while (q--) {
    long long type = read();
    if (type == 1) {
      long long l = read(), r = read();
      printf("%lld\n", cx(r) - cx(l - 1));
    } else {
      long long x = read(), len = min(n - 1, 9ll), rest = 0;
      for (long long i = len; i >= 0; --i) {
        p[n - i] += x / sum[i];
        x %= sum[i];
      }
      for (long long i = 0; i <= len; ++i) {
        p[n - i] += rest;
        rest = p[n - i] / (i + 1);
        p[n - i] %= (i + 1);
        if (i == len && rest) ++len;
      }
      for (long long i = 0; i <= len; ++i)
        xg(n - i, -a[n - i]), XG(1, n, a[n - i], 1, 1);
      for (long long i = len; i >= 0; --i) {
        a[n - i] = CX(1, n, p[n - i] + 1, 1);
        xg(n - i, a[n - i]);
        XG(1, n, a[n - i], -1, 1);
      }
    }
  }
  return 0;
}
