#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
long long power(long long a, long long b, long long c) {
  long long res = 1;
  while (b) {
    if (b & 1LL) res = (res * a) % c;
    a = (a * a) % c;
    b /= 2;
  }
  return res;
}
void solve() {
  int n, i;
  cin >> n;
  int good = 0, bad = 0, even = 0;
  for (i = 0; i < n; i++) {
    string s;
    cin >> s;
    int m = s.length();
    if (m & 1)
      good++;
    else {
      int z = 0;
      for (char c : s) {
        if (c == '0') z++;
      }
      if (z & 1)
        bad++;
      else
        even++;
    }
  }
  int ans = n;
  if (bad % 2 == 1 && good == 0) ans--;
  cout << ans << endl;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
