#include<bits/stdc++.h>
using namespace std;
int main()
{
int T;
cin >> T;
while (T--)
{
int arr[33];
for (int i = 0; i < 32; i++) scanf_s("%d", &arr[i]);
int cn = arr[0];
sort(arr, arr + 32);
//for (int i = 0; i < 32; i++)printf("%d", arr[i]);
for (int i = 0; i < 32; i++) if (cn == arr[i]) cn = 32-i;
printf("cn=%d\n", cn);
if (cn == 1) printf("1\n");
else if (cn <= 2 || cn >= 17)printf("2\n");
else if (cn == 18)printf("4\n");
else if (cn >= 19 || cn <= 26)printf("8\n");
else if (cn <= 27 || cn >= 30)printf("16\n");
else printf("32\n");
}
return 0;
}