#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
typedef long long ll;
const int N = 1e6 + 10;
const int mod = 998244353;;
void solve() {
vector<int> a(33,0);
int chn = a[1];
cin>>chn;
int cnt = 0;
for (int i = 1; i <= 31; ++i) {
cin>>a[i];
if(a[i] < chn){
cnt++;
}
}
if(cnt <= 1){
cout<<"32"<<endl;
} else if(cnt <= 5){
cout<<"16"<<endl;
} else if(cnt <= ){
cout<<"8"<<endl;
} else if(cnt <= 14){
cout<<"4"<<endl;
} else if(cnt <= 30){
cout<<"2"<<endl;
} else {
cout<<"1"<<endl;
}
}
signed main() {
//ios::sync_with_stdio(false);cin.tie(0);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}