#include <bits/stdc++.h>
using namespace std;
char s[100];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n;
    scanf("%d", &n);
    int c0 = 0, c1 = 0, odd = 0;
    for (int i = 1; i <= n; ++i) {
      scanf("%s", s);
      int len = strlen(s);
      odd += (len & 1);
      for (int j = 0; j < len; ++j)
        if (s[j] == '0')
          ++c0;
        else
          ++c1;
    }
    if (odd == 0 && (c0 & 1) && (c1 & 1))
      printf("%d\n", n - 1);
    else
      printf("%d\n", n);
  }
  return 0;
}
