#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int q;
  cin >> q;
  while (q--) {
    long long n, o = 0, z = 0, odd = 0, even = 0;
    cin >> n;
    string s[n];
    for (long long i = 0; i < n; i++) cin >> s[i];
    for (long long i = 0; i < n; i++) {
      if (s[i].length() % 2 == 0)
        even++;
      else
        odd++;
      for (long long j = 0; j < s[i].length(); j++) {
        if (s[i][j] == '1')
          o++;
        else
          z++;
      }
    }
    if (o % 2 != 0 && z % 2 != 0 && odd == 0)
      cout << n - 1 << "\n";
    else
      cout << n << "\n";
  }
  return 0;
}
