#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef float f;
int lowbit(int x){return x&-x;}
void solve()
{
int a[35];
for(int i=1;i<=32;i++)
{
cin>>a[i];
}
int count=a[1];
sort(a+1,a+33,greater<int>());
for(int i=1;i<=32;i++)
{
if(a[i]==count){count=i;break;}
}1
if(count==1)cout<<1;
else if(count>=2&&count<=5)cout<<2<<endl;
else if(count>=6&&count<=19)cout<<4<<endl;
else if(count>=20&&count<=26)cout<<8<<endl;
else if(count>=27&&count<=30)cout<<16<<endl;
else cout<<32<<endl;
}
int main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//t=1;
cin>>t;
while(t--)
{
solve();
}
return 0 ;
}