#include <stdio.h>
#include <string.h>
int countOnes(char s[], int n) {
int count = 0;
for (int i = 0; i < n; i++) {
if (s[i] == '1') {
count++;
}
}
return count;
}
int main() {
int t;
scanf("%d", &t);
while (t--) {
int n;
scanf("%d", &n);
char s[n+1];
scanf("%s", s);
int o = countOnes(s, n);
int z = n - o;
if (o == 0) {
printf("%d\n", n);
} else {
if (o % 2 == 0) {
printf("0\n");
} else {
printf("1\n");
}
}
}
return 0;
}
4th code c++