#include <bits/stdc++.h>
using namespace std;
long long calc(string s) {
  long long i, j, len = 0, n, m, cnt = 0;
  len = s.size();
  for (i = 0; i < len; i++) {
    m = s[i] - '0';
    if (m == 0) {
      cnt++;
    }
  }
  if (cnt % 2 == 1) {
    return 1;
  } else {
    return -1;
  }
}
int main() {
  long long i, j, a, b, c = 0, n, m, k, o_s = 0, b_s = 0;
  cin >> n;
  while (n--) {
    b_s = 0, o_s = 0;
    cin >> m;
    string st;
    for (i = 1; i <= m; i++) {
      cin >> st;
      long long len = st.size();
      if (len % 2 == 1) {
        o_s++;
      } else {
        k = calc(st);
        if (k == 1) {
          b_s++;
        }
      }
    }
    if (o_s == 0 && b_s % 2 == 1) {
      cout << m - 1 << endl;
    } else {
      cout << m << endl;
    }
  }
}
