#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
map<pair<int,int>,int> mp,lz;
struct segment{
void flush(int il,int ir){
if(lz[{il,ir}]==0) return;
mp[{il,ir}]=ir-il+1;
if(il!=ir){
int mid=(il+ir)/2;
lz[{il,mid}]=1;
lz[{mid+1,ir}]=1;
}
lz[{il,ir}]=0;
}
void upd(int il,int ir,int l,int r){
flush(il,ir);
if(ir<l||il>r) return;
if(l<=il&&ir<=r){
lz[{il,ir}]=1;
flush(il,ir);
return;
}
int mid=(il+ir)>>1;
upd(il,mid,l,r);
upd(mid+1,ir,l,r);
mp[{il,ir}]=mp[{il,mid}]+mp[{mid+1,ir}];
// cout<<il<<' '<<ir<<' '<<mp[{il,ir}]<<'\n';
}
void upd(int l,int r){upd(1,1e9,l,r);}
ll qry(int il,int ir,int l,int r){
flush(il,ir);
if(ir<l||il>r) return 0;
if(l<=il&&ir<=r){
return mp[{il,ir}];
}
int mid=(il+ir)>>1;
return qry(il,mid,l,r)+qry(mid+1,ir,l,r);
}
ll qry(int l,int r){return qry(1,1e9,l,r);}
}t;
int main(){
cin.tie(0)->sync_with_stdio(0);
int m;cin>>m;
int now=0;
while(m--){
int opr,x,y;cin>>opr>>x>>y;
if(opr==1){
int tmp=t.qry(x+now,y+now);
cout<<tmp<<'\n';
now=tmp;
}
else t.upd(x+now,y+now);
}
}