#include <bits/stdc++.h>
using namespace std;
int64_t mod = 1e9 + 7;
int64_t mod1 = 1e9 + 6;
int64_t power(int64_t a, int64_t b) {
  if (b == 0)
    return 1;
  else if (b % 2 == 0)
    return power((((a % mod) * (a % mod)) % mod), b / 2) % mod;
  else
    return ((a % mod) * (power((((a % mod) * (a % mod)) % mod), b / 2) % mod)) %
           mod;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int64_t q;
  cin >> q;
  while (q--) {
    int64_t n;
    cin >> n;
    int64_t c = 0, c1 = 0, c2 = 0, x = 0;
    for (int64_t i = 0; i < n; ++i) {
      string s;
      cin >> s;
      for (int64_t i = 0; i < s.length(); ++i) {
        if (s[i] == '0') c++;
        if (s[i] == '1') c1++;
      }
      if (int64_t(s.length()) % 2) c2++;
      x += int64_t(s.length()) / 2;
    }
    if (c1 / 2 + c / 2 >= x) {
      cout << n << '\n';
    } else {
      cout << n - 1 << '\n';
    }
  }
}
