#include "bits/stdc++.h"
using namespace std;
using i64 = int64_t;
using ll = long long;
void solve() {
int p = 0;
vector<int> a(32);
for (int i = 0; i < 32; i++) {
cin >> a[i];
p += a[i] < a[0];
}
auto b = a;
sort(b.begin(), b.end());
int p = lower_bound(b.begin(), b.end(), a[0]) - b.begin() + 1;
if (p < 2) {
cout << "32\n";
} else if (p < 6) {
cout << "16\n";
} else if (p < 13) {
cout << "8\n";
} else if (p < 27) {
cout << "4\n";
} else if (p < 31) {
cout << "2\n";
} else {
cout << "1\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
/*
4
2
1 2
2
2 2
7
1 1 1 2 2 2 2
3
1 2 3
*/