#include <bits/stdc++.h>
using namespace std;
char s[64];
int n;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    int alleven = 1, ones = 0;
    for (int i = 0; i < n; i++) {
      scanf("%s", s);
      int m = strlen(s);
      if (m % 2) alleven = 0;
      for (int j = 0; j < m; j++) ones += s[j] - '0';
    }
    int ans = n;
    if (alleven && ones % 2 == 1) ans--;
    printf("%d\n", ans);
  }
  return 0;
}
