#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int q;
  cin >> q;
  while (q--) {
    int n, ans = 0, o = 0, z = 0;
    string s;
    vector<int> v;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> s;
      if (s.size() % 2 == 0) {
        v.push_back(s.size() / 2);
      } else {
        ans++;
      }
      for (int j = 0; j < s.size(); j++) {
        if (s[j] == '0') {
          z++;
        } else {
          o++;
        }
      }
    }
    int t = z / 2 + o / 2;
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++) {
      if (v[i] > t) {
        break;
      }
      ans++;
      t -= v[i];
    }
    cout << ans << endl;
  }
  return 0;
}
