#include <iostream>
#include <string>
using namespace std;
int main() {
int N;
cin >> N;
for (int i=0; i<N; i++) {
int result; // 1 : win, 0 : lose
int len;
cin >> len;
long long arr[len];
for (int j=0; j<len; j++) {
cin >> arr[j];
}
if (len % 2 == 0) { // len is even
result = 0; // lose
for (int j=0; j<len; j++) {
if (arr[j] % 2 == 0) {
result = 1; // win if even exists
}
}
} else { // len is odd
result = 0; // lose
int arr_exp2[len];
for (int j=0; j<len; j++) {
arr_exp2[j] = 0;
long long elt = arr[j];
while (elt % 2 == 0) {
elt /= 2;
arr_exp2[j]++;
}
}
for (int j=1; j<len; j++) {
if (arr_exp2[j] != arr_exp2[0]) {
result = 1;
}
}
}
cout << result <<'\\n';
}
}