#include <bits/stdc++.h>
using namespace std;
const int N = 15;
int A[N];
long long sums[N + 1];
long long counters[N - 1];
long long offset = 0;
long long factorial[N + 1];
inline int counter(int i) { return (offset / factorial[i + 1]) % (i + 2); }
void do_recompute(int n) {
  bitset<N> bs(0);
  for (int j = 0; j < min(n, N) - 1; j++) {
    int i = 0;
    int c = counter(min(n, N) - 2 - j);
    while (c >= 0) {
      if (!bs.test(i)) {
        c--;
      }
      i++;
    }
    A[j] = i;
    sums[j + 1] = sums[j] + A[j];
    bs.set(i - 1);
  }
  int i = 0;
  while (bs.test(i)) i++;
  A[min(n, N) - 1] = i + 1;
  sums[min(n, N)] = sums[min(n, N) - 1] + A[min(n, N) - 1];
}
int main() {
  int n, q;
  bool recompute = true;
  scanf("%d %d", &n, &q);
  long long base_sum =
      n > N ? ((((long long)(n - N)) * ((long long)(n - N + 1))) / 2LL) : 0LL;
  factorial[0] = 1;
  for (int i = 1; i < N + 1; i++) {
    factorial[i] = factorial[i - 1] * i;
  }
  for (int iq = 0; iq < q; iq++) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      int l, r;
      scanf("%d %d", &l, &r);
      if (recompute) {
        do_recompute(n);
        recompute = false;
      }
      long long sum_l;
      long long sum_r;
      if (n > N) {
        sum_l =
            l - 1 >= n - N
                ? base_sum + sums[l - 1 - (n - N)] +
                      (((long long)(l - 1 - (n - N))) * ((long long)(n - N)))
                : (((long long)(l - 1)) * ((long long)(l))) / 2LL;
        sum_r = r >= n - N
                    ? base_sum + sums[r - (n - N)] +
                          (((long long)(r - (n - N))) * ((long long)(n - N)))
                    : (((long long)(r)) * ((long long)(r + 1))) / 2LL;
      } else {
        sum_l = sums[l - 1];
        sum_r = sums[r];
      }
      printf("%lld\n", sum_r - sum_l);
    } else {
      long long x;
      scanf("%lld", &x);
      offset += x;
      recompute = true;
    }
  }
  return 0;
}
