#include <bits/stdc++.h>
using namespace std;
int n, q;
long long ord = 1;
long long fac[20];
int nums[20];
bool v[20];
int a[20];
int len;
long long presum;
long long getsum(int m) {
  if (m <= 0) return 0;
  if (m <= n - len) {
    return (1 + m) * (long long)m / 2LL;
  }
  long long ret = presum;
  for (int i = 1; i <= m - (n - len); ++i) ret += a[i];
  return ret;
}
long long updiv(long long x, long long y) {
  if (x == 0) return 1;
  return (x - 1) / y + 1;
}
void work() {
  long long o = ord;
  for (int i = 1; i <= len; ++i) v[i] = 0;
  for (int i = 1; i < len; ++i) {
    long long res = updiv(o, fac[len - i]);
    long long rp = res;
    int j;
    for (j = 1; j <= len; ++j) {
      if (!v[j]) {
        --res;
        if (!res) break;
      }
    }
    v[j] = 1;
    a[i] = nums[j];
    o -= fac[len - i] * (rp - 1);
  }
  for (int j = 1; j <= len; ++j)
    if (!v[j]) a[len] = nums[j];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  fac[1] = 1;
  for (int i = 2; i <= 15; ++i) fac[i] = fac[i - 1] * i;
  cin >> n >> q;
  if (n <= 15) {
    len = n;
    for (int i = 1; i <= n; ++i) a[i] = nums[i] = i;
    presum = 0;
  } else {
    len = 15;
    for (int i = 1; i <= 15; ++i) a[i] = nums[i] = n - 15 + i;
    presum = (n - 14) * (long long)(n - 15) / 2LL;
  }
  for (int i = 1; i <= q; ++i) {
    int x;
    cin >> x;
    if (x == 1) {
      int l, r;
      cin >> l >> r;
      cout << getsum(r) - getsum(l - 1) << endl;
    } else {
      cin >> x;
      ord += x;
      work();
    }
  }
}
