#include <bits/stdc++.h>
using namespace std;
vector<array<int, 2> > adj[200105];
int xMove[] = {0, 1, 0, -1, 1, 1, -1, -1, 2, 2, -2, -2, 1, 1, -1, -1};
int yMove[] = {1, 0, -1, 0, 1, -1, 1, -1, 1, -1, 1, -1, 2, -2, 2, -2};
int main() {
  cin.tie(0), cout.tie(0);
  ios_base::sync_with_stdio(0);
  cout.setf(ios::fixed);
  cout.precision(10);
  int TC = 1;
  int n, m, k, q, t;
  cin >> TC;
  for (int t1 = 1; t1 <= TC; t1++) {
    cin >> n;
    vector<int> vec;
    int one = 0, zero = 0;
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      vec.push_back(s.size());
      for (char c : s)
        if (c == '1')
          one++;
        else
          zero++;
    }
    int ans = 0;
    for (int len : vec) {
      while (len > 1) {
        if (one > 1)
          len -= 2, one -= 2;
        else if (zero > 1)
          len -= 2, zero -= 2;
        else
          break;
      }
      if (len <= 1) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
