#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    int one = 0, zero = 0;
    vector<int> v;
    for (int i = 0; i < n; i++) {
      cin >> s;
      for (int j = 0; j < s.size(); j++) {
        one += s[j] == '1';
        zero += s[j] == '0';
      }
      v.push_back(s.size());
    }
    sort(v.begin(), v.end());
    int ans = 0;
    for (int j = 0; j < v.size(); j++) {
      if (v[j] % 2 == 1) {
        if (one % 2 == 1) {
          one--;
          v[j]--;
        } else if (zero % 2 == 1) {
          zero--;
          v[j]--;
        } else {
          if (one >= zero)
            one--;
          else
            zero--;
          v[j]--;
        }
      }
    }
    for (int j = 0; j < v.size(); j++) {
      ans += v[j] == 0;
      if (v[j] == 0) continue;
      if (one >= v[j]) {
        ans++;
        one -= v[j];
      } else if (zero >= v[j]) {
        zero -= v[j];
        ans++;
      } else {
        for (int k = 0; k <= one; k++) {
          if (k % 2 == 0 && zero >= v[j] - k) {
            ans++;
            one -= k;
            zero -= v[j] - k;
            break;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
