#include <bits/stdc++.h>
using LL = long long;
const int maxn = 200000 + 10;
const int maxf = 14;
int n, q;
int a[maxn];
LL fac[maxf + 1];
std::vector<int> get_permutation(int n, LL id) {
  bool vis[maxf + 1];
  memset(vis, false, sizeof(vis));
  std::vector<int> ans;
  for (int i = 0; i < n; i++) {
    int r = id / fac[n - 1 - i];
    id = id % fac[n - 1 - i];
    int a;
    for (a = 1; a <= maxf; a++)
      if (!vis[a]) {
        if (!r) break;
        r--;
      }
    ans.push_back(a);
    vis[a] = true;
  }
  return ans;
}
void preprocess() {
  fac[0] = 1;
  for (int i = 1; i <= maxf; i++) fac[i] = fac[i - 1] * i;
}
int main() {
  preprocess();
  scanf("%d%d", &n, &q);
  bool dirty = false;
  LL x = 0;
  if (n <= maxf) {
    std::vector<int> p;
    for (int i = 1; i <= n; i++) p.push_back(i);
    while (q--) {
      int type, l, r;
      scanf("%d%d", &type, &l);
      if (type == 1) {
        if (dirty) {
          p = get_permutation(n, x);
          dirty = false;
        }
        scanf("%d", &r);
        int ans = 0;
        for (int i = l - 1; i < r; i++) ans += p[i];
        printf("%d\n", ans);
      } else {
        x += l;
        dirty = true;
      }
    }
    return 0;
  }
  int offset = n - maxf;
  std::vector<int> p;
  for (int i = 1; i <= maxf; i++) p.push_back(i);
  while (q--) {
    int type, l, r;
    scanf("%d%d", &type, &l);
    if (type == 1) {
      if (dirty) {
        p = get_permutation(maxf, x);
        dirty = false;
      }
      scanf("%d", &r);
      LL ans = 0;
      if (l <= offset) {
        int qr = std::min(r, offset);
        ans += (LL)(l + qr) * (qr - l + 1) / 2;
      }
      if (r > offset) {
        int ql = std::max(offset + 1, l);
        for (int i = ql; i <= r; i++) ans += p[i - offset - 1];
        ans += offset * (r - ql + 1);
      }
      printf("%lld\n", ans);
    } else {
      dirty = true;
      x += l;
    }
  }
  return 0;
}
