#include <bits/stdc++.h>
using namespace std;
template <typename T>
void pr(vector<T> &v) {
  for (int i = 0; i < (int)(v).size(); i++) cout << v[i] << " ";
  cout << endl;
}
template <typename T>
void pr(vector<vector<T>> &v) {
  for (int i = 0; i < (int)(v).size(); i++) {
    pr(v[i]);
  }
}
template <typename T>
void re(T &first) {
  cin >> first;
}
template <typename T>
void re(vector<T> &a) {
  for (int i = 0; i < (int)(a).size(); i++) re(a[i]);
}
template <class Arg, class... Args>
void re(Arg &first, Args &...rest) {
  re(first);
  re(rest...);
}
template <typename T>
void pr(T first) {
  cout << first << endl;
}
template <class Arg, class... Args>
void pr(const Arg &first, const Args &...rest) {
  cout << first << " ";
  pr(rest...);
  cout << endl;
}
template <typename T>
void pr1(string &first, T &second) {
  cout << first << ": " << second << endl;
}
int main() {
  int t;
  re(t);
  for (int tt = 0; tt < t; tt++) {
    int n;
    re(n);
    string s;
    vector<int> v(n);
    int cnt0 = 0;
    int cnt1 = 0;
    for (int i = 0; i < n; i++) {
      re(s);
      v[i] = (int)(s).size() / 2;
      for (int j = 0; j < (int)(s).size(); j++) {
        if (s[j] == '1')
          cnt1++;
        else
          cnt0++;
      }
    }
    int have = cnt1 / 2 + cnt0 / 2;
    sort(v.begin(), v.end());
    int sum = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
      sum += v[i];
      if (sum <= have)
        ans++;
      else
        break;
    }
    pr(ans);
  }
}
