#include using namespace std; #define fr first #define sc second #define pb push_back typedef long long ll; typedef pairpii; const int inf = 0x3f3f3f3f; const int mod = 1000000007; const double pi = acos(-1.0); const ll INF = 0x3f3f3f3f3f3f3f3f; #define rep(i,x,y) for(auto i=(x);i<=(y);++i) #define dep(i,x,y) for(auto i=(x);i>=(y);--i) const int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 }; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll poww(ll a, ll b) { ll s = 1; while (b) { if (b & 1)s = (s * a) % mod; a = (a * a) % mod; b >>= 1; }return s % mod; } /*----------------------------------------------------------------------------------------------------------------------*/ const int N = 5e6 + 11; int n,m; int a[N]; int z[N]; inline void read(int &x){ x=0;bool f=0; char ch=getchar(); while(!isdigit(ch)) {if(ch=='-') f=1;ch=getchar();} while(isdigit(ch)) {x=x*10+ch-'0';ch=getchar();} x=f?(~x)+1:x; } inline int lowbit(int x) { return x&-x; } inline int query(int x) { int sum=0; for(int i=x;i;i-=lowbit(i))sum+=a[i]; return sum; } inline void update(int x,int j) { for(int i=x;i<=n;i+=lowbit(i))a[i]+=j; } void solve() { read(n); register int l,r,mid,ans,b,c,d,now; for(register int i=1;i<=n;i++) { read(b);read(c); if(b==1) { d=z[c]; if(d==0)update(c,1),z[c]=1; } else { l=0,r=n; while(l<=r) { mid=(l+r)/2; now=query(mid); if(mid>=c)now+=1-z[c]; if(now==mid)l=mid+1,ans=mid; else r=mid-1; } cout<> T; while (T--)solve(); return 0; }