#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    long long one = 0, zero = 0;
    vector<int> p(n), cp(n);
    string s;
    for (int i = 0; i < n; i++) {
      cin >> s;
      for (int j = 0; j < s.length(); j++) {
        if (s[j] == '1')
          one++;
        else
          zero++;
      }
      p[i] = s.length() / 2;
    }
    long long tp = one / 2 + zero / 2;
    sort(p.begin(), p.end());
    cp[0] = p[0];
    for (int j = 1; j < n; j++) cp[j] = cp[j - 1] + p[j];
    vector<int>::iterator it;
    it = upper_bound(cp.begin(), cp.end(), tp);
    int ans = (it - cp.begin());
    cout << ans << endl;
  }
  return 0;
}
