#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print_vector(vector<T> path) {
  copy(path.begin(), path.end(), ostream_iterator<T>(cout, " "));
  cout << endl;
}
template <typename T>
void print_array(T a, long long n) {
  for (long long i = 0; i < n; i++) cout << a[i] << " ";
  cout << endl;
}
vector<long long> take_input(long long n) {
  vector<long long> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  return v;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long test;
  cin >> test;
  while (test--) {
    long long n, size;
    cin >> n;
    string str;
    long long count = 0, one = 0, zero = 0, one_zero = 0;
    for (long long i = 0; i < n; i++) {
      cin >> str;
      size = str.length();
      one = 0;
      zero = 0;
      for (long long j = 0; j < size; j++) {
        if (str[j] == '0')
          zero++;
        else
          one++;
      }
      if (zero % 2 == 1 && one % 2 == 1)
        count++;
      else if (zero % 2 != one % 2)
        one_zero = 1;
    }
    cout << n - (count) % 2 + (one_zero == 1 && count % 2 == 1) << endl;
  }
  return 0;
}
