#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using db = long double;
using ii = pair<int, int>;
const int N = 5e5 + 5, LG = 19, MOD = 1e9 + 7;
const int SQ = 225;
const long double EPS = 1e-7;
string s;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int _;
  cin >> _;
  while (_--) {
    int n;
    cin >> n;
    int cnt[2] = {};
    vector<int> v;
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      v.push_back(s.size() / 2);
      for (auto c : s) cnt[c - '0']++;
    }
    cnt[0] /= 2;
    cnt[1] /= 2;
    sort(v.begin(), v.end());
    int sum = cnt[0] + cnt[1];
    int ans = 0;
    for (auto x : v)
      if (x <= sum) {
        sum -= x;
        ans++;
      }
    cout << ans << '\n';
  }
  return 0;
}
