#include<bits/stdc++.h>
using namespace std;
inline int read()
{
int n=0,f=1,ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
n=n*10+ch-'0';
ch=getchar();
}
return n*f;
}
int a[33];
int main()
{
int t;
t=read();
for(int greg=1;greg<=t;greg++)
{
for(int i=1;i<=32;i++)a[i]=read();
int sl=0;
for(int i=1;i<=32;i++)if(a[i]>a[1])sl++;
if(sl==0)printf("1\n");
else if(sl<=4)printf("2\n");
else if(sl<=18)printf("4\n");
else if(sl<=25)printf("8\n");
else if(sl<=29)printf("16\n");
else printf("32\n");
}
}