#include using namespace std; #define REP(i,n)for(int i=0;i<(n);++i) #define REP1(i,n)for(int i=1;i<=(n);++i) #define FORE(...)for(auto&&__VA_ARGS__) #define ALL(x)begin(x),end(x) #define mset(x,y)memset(x,y,sizeof x) #define pb push_back #define eb emplace_back #define V vector #define lb(x,y)(lower_bound(begin(x),end(x),y)-begin(x)) #define ub(x,y)(upper_bound(begin(x),end(x),y)-begin(x)) templateinline bool chmin(T&A,S B){return A>B?A=B,1:0;} templateinline bool chmax(T&A,S B){return A; using PLL=pair; #include int OP(int a,int b){return a+b;} int E(){return 0;} int main(){ fastIO(); int N,Q;cin>>N>>Q; Int A[N]; REP(i,N)cin>>A[i]; int li[N]; mset(li,-1); int ls=-1; int op[Q],k[Q];Int x[Q]; REP(i,Q){ cin>>op[i]; if(op[i]==1)cin>>k[i]>>x[i],--k[i]; if(op[i]==3)cin>>k[i],--k[i]; } Vvs; REP(i,N)vs.pb(A[i]); REP(i,Q)if(op[i]==1)vs.pb(x[i]); sort(ALL(vs)); vs.erase(unique(ALL(vs)),end(vs)); atcoder::segtreeST(size(vs)); mapmp; REP(i,N){ int id=lb(vs,A[i]); mp[i]=A[i]; ST.set(id,ST.get(id)+1); } Vse; REP(i,Q){ if(op[i]==1){ A[k[i]]=x[i]; li[k[i]]=i; se.eb(k[i],-i); } if(op[i]==2){ sort(ALL(se)); Vupd; REP(j,size(se)){ if(j&&se[j].first==se[j-1].first)continue; se[j].second*=-1; int id=ST.max_right(0,[&](int semi){return semi=ls){ cout<