#include using namespace std; typedef long long LL; const int N=5000020; int n; bool b[N]; void read(int &hy) { hy=0; char cc=getchar(); while(cc<'0'||cc>'9') cc=getchar(); while(cc>='0'&&cc<='9') { hy=(hy<<3)+(hy<<1)+cc-'0'; cc=getchar(); } } int main() { cin>>n; int now1=1,now2=2; for(int i=1;i<=n;i++) { int op,x; read(op); read(x); if(op==1) { b[x]=1; if(x==now1) { now1=now2; now2++; while(b[now2]) now2++; } else { while(b[now2]) now2++; } } if(op==2) { if(x==now1) { printf("%d\n",now2); } else printf("%d\n",now1); } } return 0; }