#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    vector<string> v(n);
    long long int o = 0, z = 0, oddl = 0;
    for (long long int i = 0; i < n; i++) {
      cin >> v[i];
      for (long long int j = 0; j < v[i].size(); j++) {
        if (v[i][j] == '1')
          o++;
        else
          z++;
      }
      oddl += v[i].size() % 2;
    }
    if (oddl == 0) {
      if (o % 2 == 1 || z % 2 == 1)
        cout << n - 1 << endl;
      else
        cout << n << endl;
    } else {
      oddl %= 2;
      if ((o + z - oddl) % 2 == 1)
        cout << n - 1 << endl;
      else
        cout << n << endl;
    }
  }
  return 0;
}
