#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, n, g, k, m, mx = 0, mn = 1e9, c, res, c1, x, y, w, z, c2;
  scanf("%lld", &t);
  for (long long int ca = 1; ca <= t; ca++) {
    cin >> n;
    vector<string> a(n);
    res = 0;
    for (long long int i = 0; i < n; i++) cin >> a[i];
    long long int one = 0, zero = 0;
    for (long long int i = 0; i < n; i++) {
      string st = a[i];
      if (st.size() % 2)
        res++;
      else {
        for (long long int j = 0; j < st.size(); j++) {
          if (st[j] == '1')
            one++;
          else
            zero++;
        }
      }
    }
    if (res == 0 && zero & 1) n--;
    cout << n << endl;
  }
}
