#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long int, long long int> p1,
         pair<long long int, long long int> p2) {
  return ((p1.first > p2.first));
}
long long int emp[1000001];
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long int t;
  cin >> t;
  for (long long int i = 0; i < t; i++) {
    long long int n;
    cin >> n;
    string s[n];
    for (long long int i = 0; i < n; i++) cin >> s[i];
    long long int unset = 0, odd = 0, set = 0;
    for (long long int i = 0; i < n; i++) {
      if (s[i].length() % 2 != 0) {
        cout << n << endl;
        odd++;
        break;
      } else {
        long long int count = 0;
        for (long long int j = 0; j < s[i].length(); j++)
          if (s[i][j] == '0') count++;
        if (count % 2 != 0)
          unset++;
        else
          set++;
      }
    }
    if (odd == 0) cout << set + unset - unset % 2 << endl;
  }
  return 0;
}
