#include <bits/stdc++.h>
using namespace std;
int N, M, a[200001];
long long c[200001], sum, fc[20];
bool vis[20];
int get() {
  int x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x;
}
void put(long long x) {
  if (x >= 10) put(x / 10);
  putchar(x % 10 + '0');
}
void upd(int x, int v) {
  for (int i = x; i <= N; i += i & -i) c[i] += v;
}
long long ask(int x) {
  long long ans = 0;
  for (int i = x; i; i -= i & -i) ans += c[i];
  return ans;
}
void upd1(long long x) {
  for (int i = 1; i <= N; i++) vis[i] = 0;
  for (int i = 1; i <= N; i++) {
    int id = 0, cnt = 0;
    while (cnt <= x / fc[N - i]) {
      id++;
      while (vis[id]) id++;
      cnt++;
    }
    vis[id] = 1, upd(i, id - a[i]), a[i] = id, x %= fc[N - i];
  }
}
void upd2(long long x) {
  for (int i = 1; i <= 15; i++) vis[i] = 0;
  for (int i = 1; i <= 15; i++) {
    int id = 0, cnt = 0;
    while (cnt <= x / fc[15 - i]) {
      id++;
      while (vis[id]) id++;
      cnt++;
    }
    vis[id] = 1, upd(N - 15 + i, N - 15 + id - a[N - 15 + i]),
    a[N - 15 + i] = N - 15 + id, x %= fc[15 - i];
  }
}
void sol1() {
  for (int i = 1; i <= M; i++) {
    int opt = get(), x = get(), y;
    opt == 1 ? put(ask(y = get()) - ask(x - 1)), putchar('\n'),
        0    : (upd1(sum += x), 0);
  }
}
void sol2() {
  for (int i = 1; i <= M; i++) {
    int opt = get(), x = get(), y;
    opt == 1 ? put(ask(y = get()) - ask(x - 1)), putchar('\n'),
        0    : (upd2(sum += x), 0);
  }
}
int main() {
  N = get(), M = get();
  for (int i = 1; i <= N; i++) a[i] = i, upd(i, i);
  fc[0] = 1;
  for (int i = 1; i <= 15; i++) fc[i] = fc[i - 1] * i;
  N <= 15 ? sol1() : sol2();
  return 0;
}
