#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  string str;
  long long odd = 0;
  long long goodEven = 0;
  long long badEve = 0;
  for (long long i = 0; i < n; i++) {
    cin >> str;
    long long len = str.size();
    long long noOfEven = 0;
    for (long long j = 0; j < len; j++) {
      if (str[j] == '0') noOfEven++;
    }
    if (len % 2 == 1)
      odd++;
    else if (noOfEven % 2 == 0)
      goodEven++;
    else
      badEve++;
  }
  cout << n - ((odd == 0 && badEve % 2 == 1) ? 1 : 0) << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
