# [联合集训6-18] 栈 吉司机线段树


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 200010
#define ll long long
#define mid (l+r>>1)
#define lc(v) (v<<1)
#define rc(v) (v<<1|1)
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
int n,m,cnt[N],pnt[N];
ll ans[N];
{
int x=0,f=1;char ch=getchar();
for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=-1;
for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
return x*f;
}
struct node
{
int opt,l,r,x;
}q[N];

struct tree
{
int mi[N<<2],se[N<<2];
void update(int v)
{
int x=lc(v),y=rc(v);
if(mi[x]==mi[y]){mi[v]=mi[x];se[v]=min(se[x],se[y]);return ;}
if(mi[x]>mi[y]) swap(x,y);
mi[v]=mi[x];se[v]=min(se[x],mi[y]);
}
void pushdown(int v)
{
}
void cal(int v,int d)
{
if(mi[v]>=d) return ;
pushdown(v),cal(lc(v),d),cal(rc(v),d);
update(v);
}
void build(int v,int l,int r)
{
build(lc(v),l,mid);
build(rc(v),mid+1,r);
update(v);
}
void clr(int v,int l,int r,int x)
{
pushdown(v);
if(x<=mid) clr(lc(v),l,mid,x);
else clr(rc(v),mid+1,r,x);
update(v);
}
void mdf(int v,int l,int r,int lx,int rx,int d)
{
if(l==lx&&r==rx){cal(v,d);return ;}
pushdown(v);
if(rx<=mid) mdf(lc(v),l,mid,lx,rx,d);
else if(lx>mid) mdf(rc(v),mid+1,r,lx,rx,d);
else mdf(lc(v),l,mid,lx,mid,d),mdf(rc(v),mid+1,r,mid+1,rx,d);
update(v);
}
void travel(int v,int l,int r)
{
pushdown(v);
travel(lc(v),l,mid);
travel(rc(v),mid+1,r);
update(v);
}
}T;
int main()
{
freopen("stack.in","r",stdin);
freopen("stack.out","w",stdout);
for(int i=1;i<=m;i++)
{
}
for(int i=1;i<=n;i++)
cnt[i]+=cnt[i-1],pnt[i]=cnt[i-1]+1;
int all=cnt[n];
T.build(1,1,all);

for(int i=m;i;i--)
if(q[i].opt==1)
{
if(cnt[q[i].l-1]<cnt[q[i].r])T.mdf(1,1,all,cnt[q[i].l-1]+1,cnt[q[i].r],q[i].x);
}
else
T.clr(1,1,all,pnt[q[i].x]),pnt[q[i].x]++;
T.travel(1,1,all);
for(int i=1;i<=m;i++)
if(q[i].opt==2)
printf("%lld\n",ans[--pnt[q[i].x]]);

return 0;
}