#include #include #include #include #include #include using namespace std; int T,n; int first[5000020]; int last[5000020]; int mp[5000020]; int get(){ char t = getchar(); while(t < '0' || t > '9')t=getchar(); int x = 0; while(t>='0' && t <= '9'){ x *= 10; x += t-'0'; t = getchar(); } return x; } int sta[5000020]; int top; int getfirst(int x){ top = 1; sta[1] = first[x]; while(first[sta[top]] != sta[top]){ sta[top+1] = first[sta[top]]; ++ top; } first[x] = sta[top]; for(int i=1;i<=top;++i)first[sta[i]] = sta[top]; return first[x]; } int getlast(int x){ top = 1; sta[1] = last[x]; while(last[sta[top]] != sta[top]){ sta[top+1] = last[sta[top]]; ++ top; } last[x] = sta[top]; for(int i=1;i<=top;++i)last[sta[i]] = sta[top]; return last[x]; } int main(){ n = get(); for(int i=1;i<=n;++i){ first[i] = last[i] = i; mp[i] = 0; } for(int i=1;i<=n;++i){ int x,y; x = get(); y = get(); if(x == 1){ mp[y] = 1; if(y > 1 && mp[y-1]){ int z = getfirst(y-1); first[y] = z; last[y-1] = y; } if(y < n && mp[y+1]){ int z = getlast(y+1); last[y] = z; first[y+1] = y; } }else{ if(y == 1){ if(mp[y+1])printf("%d\n", getlast(y+1) + 1); else printf("2\n"); }else{ if(!mp[y-1]){ if(!mp[1])printf("1\n"); else printf("%d\n", getlast(1) + 1); }else{ int z = getfirst(y-1); if(z > 1){ if(!mp[1])printf("1\n"); else printf("%d\n", getlast(1) + 1); }else{ if(y == n)printf("%d\n", n+1); else{ if(!mp[y+1])printf("%d\n", y+1); else{ int z = getlast(y+1); printf("%d\n", z+1); } } } } } } } return 0; }