```cpp
#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+5;
const int MOD=1e9+7;
int n,m;
priority_queue<int,vector<int>,greater<int> >q,p;
bool a[maxn],b[maxn];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
for(int i=1;i<=n;i++)
q.push(i);
while(m--){
int op,x;
cin>>op;
if(op==1){
p.push(q.top());
q.pop();
}
if(op==2){
cin>>x;
b[x]=1;
}
if(op==3){
while(!p.empty()&&b[p.top()]) p.pop();
cout<<p.top()<<'\n';
}
}
return 0;
}
by aCssen @ 2024-04-14 17:18:21