#include <bits/stdc++.h>
using namespace std;
struct debugger {
  static void call(string::iterator it, string::iterator ed) {}
  template <typename T, typename... aT>
  static void call(string::iterator it, string::iterator ed, T a, aT... rest) {
    string b;
    for (; *it != ','; ++it)
      if (*it != ' ') b += *it;
    cerr << b << " = " << a << " ";
    call(++it, ed, rest...);
  }
};
vector<int> A;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    int cnt[2] = {0};
    priority_queue<int, vector<int>, greater<int> > pq;
    priority_queue<int, vector<int>, greater<int> > pq1;
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      for (int j = 0; j < s.size(); j++) {
        if (s[j] == '0')
          cnt[0]++;
        else
          cnt[1]++;
      }
      pq.push(s.size());
      pq1.push(s.size());
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      int t = pq.top();
      pq.pop();
      if (cnt[0] + cnt[1] <= 0) break;
      bool b = true;
      bool od = false;
      if (t % 2 != 0) {
        t--;
        od = true;
      }
      while (t > 0) {
        if (cnt[0] >= 2) {
          t -= 2;
          cnt[0] -= 2;
        } else if (cnt[1] >= 2) {
          t -= 2;
          cnt[1] -= 2;
        } else {
          b = false;
          break;
        }
      }
      if (b) {
        if (!od)
          ans++;
        else {
          if ((cnt[0] - 1) % 2 == 0 && cnt[0] != 0) {
            cnt[0] -= 1;
          } else if ((cnt[1] - 1) % 2 == 0 && cnt[1] != 0) {
            cnt[1] -= 1;
          } else if (cnt[0] > 0) {
            cnt[0] -= 1;
          } else if (cnt[1] > 0) {
            cnt[1] -= 1;
          } else
            b = false;
          if (b) ans++;
        }
      }
    }
    cout << ans << endl;
  }
}
