#include <bits/stdc++.h>
#pragma optimize("TKACHENKO-GORYACHENKO")
#pragma GCC optimize("O3")
using namespace std;
const long long inf = 1e9;
const long long maxn = 200;
long long n, m, k;
string S[maxn];
signed main() {
  long long q, w, e, a, b, c;
  cin >> k;
  for (e = 0; e < k; e++) {
    cin >> n;
    long long cnt0 = 0, cnt1 = 0;
    bool isnc = 0;
    for (q = 0; q < n; q++) {
      cin >> S[q];
      if (S[q].length() % 2 == 1) {
        isnc = 1;
      }
      for (w = 0; w < S[q].length(); w++) {
        if (S[q][w] == '0') {
          cnt0++;
        } else {
          cnt1++;
        }
      }
    }
    if (isnc || (cnt0 % 2 == 0)) {
      cout << n << endl;
      continue;
    }
    cout << n - 1 << endl;
  }
  return 0;
}
