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