#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
long long int power(long long int x, long long int y) {
  long long int temp;
  if (y == 0) return 1;
  temp = power(x, y / 2);
  if (y % 2 == 0)
    return temp * temp;
  else
    return x * temp * temp;
}
long long int GCD(long long int A, long long int B) {
  if (B == 0)
    return A;
  else
    return GCD(B, A % B);
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  long long int t, i, j;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int c = 0, c1 = 0, tn = n;
    while (n--) {
      string s;
      cin >> s;
      if (s.size() % 2 == 1) c++;
      long long int o = 0;
      for (i = 0; i < s.size(); i++) {
        if (s[i] == '0') o++;
      }
      if (o % 2 == 1) c1++;
    }
    if (c == 0 && c1 % 2 == 1)
      cout << tn - 1 << endl;
    else
      cout << tn << endl;
  }
}
