#include <bits/stdc++.h>
using namespace std;
long long a[22], b[22], fac[22];
int vis[22];
long long solve(int n, int l, int r, long long x) {
  for (int i = 1; i <= n; i++) {
    a[i] = i;
    vis[i] = 1;
  }
  for (int i = n; i >= 1; i--) {
    long long now = x / fac[i - 1];
    long long p = x % fac[i - 1];
    int s = 0, j;
    for (j = 1; j <= n; j++) {
      s += vis[j];
      if (s > now) break;
    }
    b[i] = j;
    vis[j] = 0;
    x = p;
  }
  reverse(b + 1, b + 1 + n);
  long long ans = 0;
  for (int i = l; i <= r; i++) ans += b[i];
  return ans;
}
int main() {
  fac[0] = 1;
  for (int i = 1; i <= 15; i++) {
    fac[i] = fac[i - 1] * 1ll * i;
  }
  long long x = 0;
  int n, q;
  scanf("%d%d", &n, &q);
  while (q--) {
    int op;
    long long l, r, y;
    scanf("%d", &op);
    if (op == 1) {
      scanf("%lld%lld", &l, &r);
      if (n <= 15) {
        printf("%lld\n", solve(n, l, r, x));
      } else {
        if (r <= n - 15) {
          printf("%lld\n", 1ll * (r - l + 1) * (l + r) / 2ll);
        } else if (l <= n - 15) {
          printf("%lld\n", (l + n - 15) * (n - 15 - l + 1) / 2ll +
                               (r - n + 15) * (n - 15) +
                               solve(15, 1, r - n + 15, x));
        } else {
          printf("%lld\n",
                 (r - l + 1) * (n - 15) + solve(15, l - n + 15, r - n + 15, x));
        }
      }
    } else {
      scanf("%lld", &y);
      x += y;
    }
  }
  return 0;
}
