#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long c = 0, f = 0;
    for (long long i = 0; i < n; i++) {
      string s;
      cin >> s;
      for (long long j = 0; j < signed((s).size()); j++)
        if (s[j] == '1') c++;
      if (signed((s).size()) % 2) f = 1;
    }
    long long ans = 0;
    if (c % 2 == 0)
      ans = n;
    else {
      if (f)
        ans = n;
      else
        ans = n - 1;
    }
    cout << ans << "\n";
  }
  return 0;
}
