#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  srand(time(NULL));
  ;
  long long int n, q, x = 0, f = 0;
  cin >> n >> q;
  vector<long long int> a(n + 1);
  for (int i = 0; i < int(n + 1); i++) a[i] = (1ll * i * (i + 1) / 2);
  while (q--) {
    int t, l, r;
    cin >> t >> l;
    if (t == 1) {
      cin >> r;
      if (f) {
        long long int fa = 1, m = 1, y = x;
        while (fa <= y) fa *= ++m;
        int z = m, id;
        set<int> st;
        for (int i = n - m + 1; i <= n; i++) st.insert(i);
        for (int i = n - m + 1; i <= n; i++) {
          fa /= z;
          id = y / fa;
          auto it = st.begin();
          for (int j = 0; j < int(id); j++) it++;
          a[i] = *it;
          a[i] += a[i - 1];
          st.erase(it);
          y %= fa;
          z--;
        }
      }
      cout << a[r] - a[l - 1] << endl;
      f = 0;
    } else {
      x += l;
      f = 1;
    }
  }
  return 0;
}
