#include <bits/stdc++.h>
using namespace std;
long long n, T, sum, ans;
int main() {
  ios::sync_with_stdio(0);
  cin >> T;
  while (T--) {
    ans = sum = 0;
    cin >> n;
    for (long long i = 1; i <= n; i++) {
      string s;
      cin >> s;
      ans += s.size() & 1;
      for (long long j = 0; j < s.size(); j++) sum += s[j] - '0';
    }
    if (ans >= (sum & 1))
      cout << n << endl;
    else
      cout << n - 1 << endl;
  }
  return 0;
}
