#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, tt;
  cin >> tt;
  while (tt--) {
    long long int n, i, j, c0 = 0, c1 = 0, len = 0, sz = 0, odd = 0, temp;
    string s;
    vector<int> vec;
    cin >> n;
    for (i = 0; i < n; i++) {
      cin >> s;
      len = s.size();
      if (len & 1) odd++;
      for (j = 0; j < len; j++) {
        if (s[j] == '0')
          c0++;
        else
          c1++;
      }
    }
    temp = (c0 & 1) + (c1 & 1);
    if (odd >= temp)
      cout << n << endl;
    else
      cout << n - 1 << endl;
  }
  return 0;
}
