#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e4;
int q, n, ans, cnt;
int sum[2];
int main() {
  cin >> q;
  while (q--) {
    cin >> n;
    sum[0] = sum[1] = cnt = 0;
    for (int i = 1; i <= n; i++) {
      string s;
      cin >> s;
      for (auto x : s) {
        sum[x - '0']++;
      }
      if (s.size() & 1) cnt++;
    }
    int ss = (sum[0] & 1) + (sum[1] & 1);
    if (ss > cnt)
      cout << n - 1 << endl;
    else
      cout << n << endl;
  }
  return 0;
}
