#include <bits/stdc++.h>
using namespace std;
long long fac[16];
long long sum;
long long a[16];
int p[16];
int vis[16];
int n, q;
void get(long long qwq) {
  for (int i = 1; i <= 14; ++i) {
    a[i] = qwq / fac[15 - i];
    qwq %= fac[15 - i];
  }
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= 15; ++i) {
    int cnt = 0;
    for (int j = 1; j <= 15; ++j) {
      if (!vis[j]) ++cnt;
      if (cnt == a[i] + 1) {
        vis[j] = 1;
        p[i] = j;
        break;
      }
    }
  }
}
int main() {
  fac[0] = 1;
  for (int i = (1); i <= (15); ++i) fac[i] = fac[i - 1] * i;
  scanf("%d %d", &n, &q);
  while (q--) {
    int opt;
    long long ans = 0;
    scanf("%d", &opt);
    if (opt == 1) {
      int l, r;
      scanf("%d %d", &l, &r);
      if (r > n - 15) {
        get(sum);
        ans = 0;
        if (l > n - 15) {
          for (int i = l - (n - 15); i <= r - (n - 15); ++i) {
            ans += p[i];
          }
          ans += (r - l + 1) * (n - 15);
        } else {
          for (int i = 1; i <= r - (n - 15); ++i) {
            ans += p[i];
          }
          ans += 1LL * (r - (n - 15)) * (n - 15);
          ans += 1LL * (n - 15 - l + 1) * (l + n - 15) / 2;
        }
        cout << ans << endl;
      } else {
        ans = 1LL * (l + r) * (r - l + 1) / 2;
        cout << ans << endl;
      }
    } else {
      int x;
      scanf("%d", &x);
      sum += x;
    }
  }
  return 0;
}
