#include<bits/stdc++.h>
using namespace std;
typedef long long inr;
typedef unsigned long long unr;
typedef long double onr;
#define fr(y) for(inr i=1;i<=y;i++)
#define el <<endl
inr T,n,opt,a[10000005],b[10000005],d,p;
int main() {
ios::sync_with_stdio(false);
cin>>T;
while(T--) {
cin>>n;
for(int j=1; j<=n; j++) {
cin>>opt;
if(opt==1) {
for(int i=1000; i>=1; i--) a[i]=a[i-1];
} else {
cin>>d;
p=0;
while(d) {
b[++p]=d%2;
d/=2;
}
for(int i=1; i<=1000; i++) a[i]+=b[i],b[i]=0;
for(int i=1; i<=1000; i++) if(a[i]>=2) a[i+1]++,a[i]-=2;
}
}
int fg=0;
for(int i=1000; i>=1; i--) {
if(a[i]==1) fg=1;
if(fg==1) cout<<a[i];
}
if(fg==0) cout<<0;
cout<<endl;
}
return 0;
}