#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define debug(x) cerr<<#x<<" "; _print(x); cerr<<nline;
#else
#define debug(x);
#endif
#define ll long long
/*
------------------------Input Checker----------------------------------
*/
long long readInt(long long l,long long r,char endd){
long long x=0;
int cnt=0;
int fi=-1;
bool is_neg=false;
while(true){
char g=getchar();
if(g=='-'){
assert(fi==-1);
is_neg=true;
continue;
}
if('0'<=g && g<='9'){
x*=10;
x+=g-'0';
if(cnt==0){
fi=g-'0';
}
cnt++;
assert(fi!=0 || cnt==1);
assert(fi!=0 || is_neg==false);
assert(!(cnt>19 || ( cnt==19 && fi>1) ));
} else if(g==endd){
if(is_neg){
x= -x;
}
if(!(l <= x && x <= r))
{
cerr << l << ' ' << r << ' ' << x << '\n';
assert(1 == 0);
}
return x;
} else {
assert(false);
}
}
}
string readString(int l,int r,char endd){
string ret="";
int cnt=0;
while(true){
char g=getchar();
assert(g!=-1);
if(g==endd){
break;
}
cnt++;
ret+=g;
}
assert(l<=cnt && cnt<=r);
return ret;
}
long long readIntSp(long long l,long long r){
return readInt(l,r,' ');
}
long long readIntLn(long long l,long long r){
return readInt(l,r,'\n');
}
string readStringLn(int l,int r){
return readString(l,r,'\n');
}
string readStringSp(int l,int r){
return readString(l,r,' ');
}
/*
------------------------Main code starts here----------------------------------
*/
ll MAX=100000;
vector<ll> readv(ll n){
vector<ll> a;
ll x;
for(ll i=1;i<n;i++){
x=readIntSp(0,1);
a.push_back(x);
}
x=readIntLn(0,1);
a.push_back(x);
return a;
}
ll sum_t=0;
void solve(){
ll n=readIntLn(2,100000);
sum_t+=n;
vector<ll> a=readv(n);
vector<ll> freq(5,0);
for(auto it:a){
freq[it]++;
}
for(ll i=1;i<n;i++){
if(i&1){
if(freq[0]>0){
freq[0]--;
}
else{
freq[1]--;
}
}
else{
if(freq[1]>0){
freq[1]--;
}
else{
freq[0]--;
}
}
}
for(ll i=0;i<2;i++){
if(freq[i]){
cout<<i<<endl;
return;
}
}
return;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("error.txt", "w", stderr);
#endif
ll test_cases=readIntLn(1,1000);
while(test_cases--){
solve();
}
assert(getchar()==-1);
assert(sum_t<=(2e5));
return 0;
}