#include <bits/stdc++.h>
using namespace std;
long long q, n, res;
long long f[101];
string s[51];
int main() {
  cin >> q;
  for (; q >= 1; --q) {
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> s[i];
    bool checkodd = false;
    f['0'] = 0;
    f['1'] = 0;
    for (int i = 1; i <= n; ++i) {
      if (s[i].size() % 2 == 1) checkodd = true;
      string c = s[i];
      for (int j = 0; j < c.size(); ++j) f[c[j]] += 1;
    }
    if (checkodd == true) {
      cout << n << endl;
      continue;
    }
    if (checkodd == false && (f['1'] % 2 == 1 || f['0'] % 2 == 1)) {
      cout << n - 1 << endl;
      continue;
    }
    cout << n << endl;
  }
  return 0;
}
