#include<bits/stdc++.h>
#define pir pair<int,int>
#define fi first
#define se second
#define ll long long
#define ldb long double
#define uid uniform_int_distribution
using namespace std;
const int maxn = 5e5 + 5;
template <class t1,class t2> inline void maxi(t1 &x,t2 y){if (x < y) x = y;}
template <class t1,class t2> inline void mini(t1 &x,t2 y){if (x > y) x = y;}
struct query{
int type,v1,v2;
};
query Q[maxn];
void input(int q){
for (int i = 1 ; i <= q ; i++) cin >> Q[i].type >> Q[i].v1 >> Q[i].v2;
}
vector <int> a;
void th1(int x,int k,int cur){
int vt = 0;
vector <int> arr;
for (int i = 0 ; i < a.size() ; i++)
if (a[i] == x){
vt = i;
break;
}
for (int i = vt + 1 ; i < a.size() ; i++) arr.push_back(a[i]);
while (a.size() > vt + 1) a.pop_back();
for (int i = cur ; i < cur + k ; i++) a.push_back(i);
for (int v : arr) a.push_back(v);
}
void th2(int y,int h){
int l = 0,r = 0;
vector <int> arr;
for (int i = 0 ; i < a.size() ; i++)
if (a[i] == y){
l = i + 1,r = i + h;
break;
}
for (int i = 0 ; i < a.size() ; i++)
if (i < l || i > r) arr.push_back(a[i]);
a = arr;
}
ll th3(int l,int r){
ll res = 0;
l--;r--;
for (int i = l ; i <= r ; i++)
res += a[i];
return res;
}
int g(int x){
int n = x +1;
while (n > x) n = rand() % (x + 1) + 1;
return n;
}
int g0(int x){
int n = x + 1;
while (n > x) n = rand() % (x + 1);
return n;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
freopen("TSEQ.INP","w",stdout);
int q;
std:: mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
srand(time(NULL));
q = 500;int lim = 500;
uid <int> gk(1,lim);
cout << q << "\n";
int cur = 1;
a.push_back(0);
for (int i = 1 ; i <= q ; i++){
int type = g(3);
cout << type << " ";
if (type == 1){
int vt = g(a.size()),k = gk(rd),x = a[vt - 1];
cout << x << " " << k << "\n";
th1(x,k,cur);
cur += k;
}
if (type == 2){
//h can be zero, because of the weak test generator
int vt = g(a.size()),h = g0(a.size() - vt),y = a[vt - 1];
th2(y,h);
cout << y << " " << h << "\n";
}
if (type == 3) {
int l = g(a.size()),r = g(a.size());
if (l > r) swap(l,r);
cout << l << " " << r << "\n";
}
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBwaXIgcGFpcjxpbnQsaW50PgojZGVmaW5lIGZpIGZpcnN0CiNkZWZpbmUgc2Ugc2Vjb25kCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgbGRiIGxvbmcgZG91YmxlCiNkZWZpbmUgdWlkIHVuaWZvcm1faW50X2Rpc3RyaWJ1dGlvbiAKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY29uc3QgaW50IG1heG4gPSA1ZTUgKyA1OwoKdGVtcGxhdGUgPGNsYXNzIHQxLGNsYXNzIHQyPiBpbmxpbmUgdm9pZCBtYXhpKHQxICZ4LHQyIHkpe2lmICh4IDwgeSkgeCA9IHk7fQp0ZW1wbGF0ZSA8Y2xhc3MgdDEsY2xhc3MgdDI+IGlubGluZSB2b2lkIG1pbmkodDEgJngsdDIgeSl7aWYgKHggPiB5KSB4ID0geTt9CgpzdHJ1Y3QgcXVlcnl7CglpbnQgdHlwZSx2MSx2MjsKfTsKCnF1ZXJ5IFFbbWF4bl07Cgp2b2lkIGlucHV0KGludCBxKXsKCWZvciAoaW50IGkgPSAxIDsgaSA8PSBxIDsgaSsrKSBjaW4gPj4gUVtpXS50eXBlID4+IFFbaV0udjEgPj4gUVtpXS52MjsKfQoKCnZlY3RvciA8aW50PiBhOwoJCnZvaWQgdGgxKGludCB4LGludCBrLGludCBjdXIpewoJaW50IHZ0ID0gMDsKCXZlY3RvciA8aW50PiBhcnI7CgkJCgkJZm9yIChpbnQgaSA9IDAgOyBpIDwgYS5zaXplKCkgOyBpKyspCgkJICAgIGlmIChhW2ldID09IHgpewoJCSAgICAJdnQgPSBpOwoJCSAgICAJYnJlYWs7CgkJCX0KCQkKCQlmb3IgK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