#include <bits/stdc++.h>
using namespace std;
long long f[16];
long long sum = 0;
long long n, q;
long long a[16];
void incantor(long long k, long long n) {
  long long x;
  vector<long long> v;
  for (long long i = 1; i <= n; i++) v.push_back(i);
  for (long long i = 1; i < n; ++i) {
    a[i] = v[(x = k / f[n - i])];
    v.erase(v.begin() + x);
    k %= f[n - i];
  }
  a[n] = v[0];
}
void print() {}
int main() {
  f[0] = 1;
  for (long long i = 1; i <= 15; i++) f[i] = f[i - 1] * i;
  scanf("%lld%lld", &n, &q);
  if (n <= 15) {
    while (q--) {
      long long opt;
      scanf("%lld", &opt);
      if (opt == 1) {
        long long l, r;
        scanf("%lld%lld", &l, &r);
        long long ans = 0;
        incantor(sum, n);
        for (long long i = l; i <= r; i++) ans += a[i];
        printf("%lld\n", ans);
      } else {
        long long x;
        scanf("%lld", &x);
        sum += x;
      }
    }
  } else {
    while (q--) {
      long long opt;
      scanf("%lld", &opt);
      if (opt == 1) {
        long long l, r;
        scanf("%lld%lld", &l, &r);
        incantor(sum, 15);
        long long ans = 0;
        if (r >= n - 14) {
          long long st = n - 14;
          if (l >= n - 14) {
            for (long long i = l; i <= r; i++)
              ans += a[i - (n - 15)] + (n - 15);
          } else {
            for (long long i = n - 15 + 1; i <= r; i++)
              ans += a[i - (n - 15)] + (n - 15);
            ans += (n - 15 - l + 1) * (n - 15 + l) / 2;
          }
        } else {
          ans += (l + r) * (r - l + 1) / 2;
        }
        printf("%lld\n", ans);
      } else {
        long long x;
        scanf("%lld", &x);
        sum += x;
      }
    }
  }
  return 0;
}
