#include <bits/stdc++.h>
using namespace std;
constexpr int max_len = 14;
vector<long long> factorial;
vector<int> nth_permutation(long long n, int len) {
  vector<int> v(min(len, max_len));
  list<int> possible_num;
  for (int i = len - v.size() + 1; i <= len; i++) possible_num.push_back(i);
  --n;
  for (int i = 0; i < v.size(); i++) {
    auto it = possible_num.begin();
    advance(it, n / factorial[v.size() - i - 1]);
    v[i] = *it;
    possible_num.erase(it);
    n %= factorial[v.size() - i - 1];
  }
  return v;
}
void test_case() {
  int n, q;
  cin >> n >> q;
  long long x = 1;
  vector<int> v(min(n, max_len));
  vector<long long> prefix(v.size());
  bool need_update = true;
  while (q--) {
    int op;
    cin >> op;
    if (op == 1) {
      int l, r;
      cin >> l >> r;
      if (r <= n - v.size())
        cout << (long long)(l + r) * (r - l + 1) / 2 << '\n';
      else {
        if (need_update) {
          v = nth_permutation(x, n);
          prefix[0] = v[0];
          for (int i = 1; i < v.size(); i++) prefix[i] = prefix[i - 1] + v[i];
          need_update = false;
        }
        long long ans = prefix[r - n + v.size() - 1];
        if (l <= n - v.size() + 1)
          ans += (long long)(l + n - v.size()) * (n - v.size() - l + 1) / 2;
        else
          ans -= prefix[l - n + v.size() - 2];
        cout << ans << '\n';
      }
    } else {
      long long tmp;
      cin >> tmp;
      x += tmp;
      need_update = true;
    }
  }
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  factorial.resize(max_len);
  factorial[0] = 1;
  for (int i = 1; i < max_len; i++) factorial[i] = factorial[i - 1] * i;
  int Case = 1;
  for (int i = 1; i <= Case; i++) {
    test_case();
  }
  return 0;
}
