#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int count[2] = {0, 0};
  bool all_even = 1;
  for (int i = 0; i < n; i++) {
    static string s;
    cin >> s;
    if (static_cast<int>(s.size()) & 1) all_even = 0;
    for (const char &c : s) count[c - '0']++;
  }
  if (all_even && (count[0] & 1) && (count[1] & 1))
    cout << n - 1;
  else
    cout << n;
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
