#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int N = 1e6 + 10;
const int Mod = 0;
ll a[N], sum[N], p[N];
int n, m, T, q;
int Read();
void update(ll x) {
  vector<ll> v;
  x--;
  int cnt = 0;
  if (n <= 14) {
    for (int i = 1; i <= 14; i++) v.push_back(i);
  } else {
    for (int i = 1; i <= 14; i++) v.push_back(n - 14 + i);
  }
  for (int i = min(13, n - 1); i >= 0; i--) {
    int j = x / p[i];
    a[++cnt] = v[j];
    x %= p[i];
    v.erase(v.begin() + j);
  }
  int st = max(n - 13, 1);
  for (int i = st, xx = 1; i <= n; i++, xx++) {
    sum[i] = sum[i - 1] + a[xx];
  }
}
int main() {
  n = Read(), q = Read();
  for (int i = 1; i <= n; ++i) {
    a[i] = i;
    sum[i] = sum[i - 1] + i;
  }
  p[0] = 1;
  for (int i = 1; i <= 14; i++) p[i] = p[i - 1] * i;
  ll now = 1;
  for (int i = 1; i <= q; i++) {
    int opt;
    opt = Read();
    if (opt == 1) {
      int x = Read(), y = Read();
      printf("%lld\n", sum[y] - sum[x - 1]);
    } else {
      int x = Read();
      now += x;
      update(now);
    }
  }
  return 0;
}
int Read() {
  int val = 0, opt = 1;
  char ch;
  while (!isdigit(ch = getchar()))
    if (ch == '-') opt = -1;
  while (isdigit(ch)) (val *= 10) += ch - '0', ch = getchar();
  return val * opt;
}
