#include<bits/stdc++.h>
#define pr pair<int,int>
#define eps 1e-10
#define pi 3.141592653589793
using namespace std;
inline int read()
{
int x=0,f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int a[40],p[40];
void solve()
{
for(int i=1;i<=n;i++)
a[i]=read(),p[i]=i;
sort(p+1,p+32+1,[&](int x,int y){return a[x]<a[y];});
for(int i=1;i<=32;i++)
{
if(p[i]==1)
{
if(i==32)
return puts("1"),void();
if(i>=28)
return puts("2"),void();
if(i>=14)
return puts("4"),void();
if(i>=7)
return puts("8"),void();
if(i>=3)
return puts("16"),void();
return puts("32"),void();
}
}
}
signed main()
{
// freopen("prime.in","r",stdin);
// freopen("prime.out","w",stdout);
int Tests=read();
while(Tests--)
solve();
return 0;
}