#include using namespace std; #define int long long struct SEG{ private: int n; vector m; public: SEG(){ n = (1ll<<20); m.resize(n); } void add(int a, int w) { for (int x = a; x < n; x |= x + 1) { m[x] += w; } } int f(int k){ k--; int l = 0, now = (1ll<<19)-1, s = 0; for(int i=18;i>=0;i--){ if(s+m[now] <= k){ s += m[now]; l += (1ll<<(i+1)); now += (1ll<<(i+1)); } now -= (1ll<>N>>Q; vector A(N); for(int i=0;i>A[i]; set s; for(int x:A) s.insert(x); vector X(Q),Y(Q),Z(Q); for(int i=0;i>X[i]; if(X[i] == 1){ cin>>Y[i]>>Z[i]; s.insert(Z[i]); } if(X[i] == 3) cin>>Y[i]; } map mp,mmp; int inda = 0; for(int x:s){ mp[inda] = x; mmp[x] = inda; inda++; } for(int i=0;i m; for(int i=0;i mm; for(auto [a,b]:m){ seg.add(A[a],-1); seg.add(b,1); A[a] = b; } m = mm; } else{ int a = Y[Q]; //cout<