#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int j, i, n;
    cin >> n;
    char ara[n][55];
    int l, zero = 0, one = 0, evens = 0, odds = 0;
    for (i = 0; i < n; i++) {
      scanf("%s", ara[i]);
      l = strlen(ara[i]);
      for (j = 0; j < l; j++) {
        if (ara[i][j] == '0')
          zero++;
        else
          one++;
      }
      if (l % 2)
        odds++;
      else
        evens++;
    }
    if (zero % 2 && one % 2) {
      if (odds % 2 == 0 && odds > 1)
        cout << n << endl;
      else
        cout << n - 1 << endl;
    } else if (zero % 2 == 0 && one % 2 == 0) {
      if (odds % 2 == 0)
        cout << n << endl;
      else
        cout << n - 1 << endl;
    } else {
      if (odds % 2)
        cout << n << endl;
      else
        cout << n - 1 << endl;
    }
  }
  return 0;
}
