#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
const long long int N = 200005;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, i, j, ans = 0, tmp = 0;
    cin >> n;
    string s[n];
    for (i = 0; i < n; i++) {
      cin >> s[i];
      long long int siz = s[i].size();
      if (siz % 2) {
        tmp = 1;
        ans++;
      }
    }
    if (tmp == 1) {
      cout << n << "\n";
      continue;
    }
    long long int tmp2 = 0;
    for (i = 0; i < n; i++) {
      if (s[i].size() % 2 == 0) {
        long long int cnt0 = 0;
        long long int cnt1 = 1;
        for (j = 0; j < s[i].size(); j++) {
          if (s[i][j] == '0')
            cnt0++;
          else
            cnt1++;
        }
        if (cnt0 % 2 == 1) tmp2++;
      }
    }
    if (tmp2 % 2 == 0)
      cout << n << "\n";
    else
      cout << n - 1 << "\n";
  }
  return 0;
}
