#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int inf = 0x3f3f3f3f;
long long rd() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int maxn = 300010;
int T, n;
char s[60][60];
int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    int num1 = 0, num2 = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%s", s[i] + 1);
      int len = strlen(s[i] + 1);
      if (len % 2 == 1) num2 = 1;
      for (int j = 1; j <= len; j++) {
        if (s[i][j] == '1') num1++;
      }
    }
    if (num1 % 2 == 1 && num2 == 0) {
      printf("%d\n", n - 1);
    } else {
      printf("%d\n", n);
    }
  }
}
