#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long q;
  cin >> q;
  while (q--) {
    long long n;
    cin >> n;
    long long odd = 0, cnt0 = 0, cnt1 = 0;
    for (long long i = 1; i <= n; i++) {
      string s;
      cin >> s;
      odd |= (s.size() % 2);
      for (auto &it : s) {
        cnt0 += (it == '0');
        cnt1 += (it == '1');
      }
    }
    if (odd || (cnt0 % 2 == 0 && cnt1 % 2 == 0))
      cout << n << "\n";
    else
      cout << n - 1 << "\n";
  }
  return 0;
}
