#include #include #include using namespace std; const int MAXN=5000000; int n,seq[MAXN+5],l[MAXN+5],r[MAXN+5]; inline int read() { int ret=0;char c=0; while(c<'0'||c>'9') c=getchar(); while('0'<=c&&c<='9') { ret=ret*10+c-'0'; c=getchar(); } return ret; } int GetL(int pos) { if(pos==l[pos]) return pos; l[pos]=GetL(l[pos]); return l[pos]; } int GetR(int pos) { if(pos==r[pos]) return pos; r[pos]=GetR(r[pos]); return r[pos]; } int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { int opt=read(),x=read(); if(opt==1) { if(seq[x]==1) continue; seq[x]=1; if(seq[x-1]) l[x]=x-1,r[x-1]=x; else l[x]=x; if(seq[x+1]) l[x+1]=x,r[x]=x+1; else r[x]=x; } else { int ret1=GetL(x-1); int ret2=GetR(x+1); if(ret1==1||x==1) { if(ret2!=0) printf("%d\n",ret2+1); else printf("%d\n",x+1); } else printf("%d\n",GetR(1)+1); } } return 0; } /* 10 2 4 2 3 1 1 2 1 1 1 2 2 1 3 2 10 1 2 2 5 */