#pragma GCC optimize("Ofast","inline","-ffast-math") #pragma GCC target("avx,sse2,sse3,sse4,mmx") #include #include #include //#define int long long using namespace __gnu_pbds; using namespace std; struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; int n,pre[5000010],nxt[5000010],vis[5000010]; inline int getint() { int r=0; char ch=getchar(); while(ch<'0'||ch>'9') ch=getchar(); while(ch>='0'&&ch<='9'){ r=r*10+ch-'0'; ch=getchar(); } return r; } signed main() { n=getint(); for(int i=0;i<=n;i++) nxt[i]=i+1,pre[i+1]=i; for(int i=1;i<=n;i++){ int flag=getint(); if(flag==1){ int x=getint(); if(vis[x]) continue; vis[x]=1; nxt[pre[x]]=nxt[x]; pre[nxt[x]]=pre[x]; } else{ int x=getint(); int pos=nxt[0]; if(pos!=x) printf("%d\n",pos); else printf("%d\n",nxt[x]); } } return 0; }