#include <bits/stdc++.h>
using namespace std;
int TC;
int N, A[2], ans;
char S[100];
int main() {
  int i, j;
  scanf("%d", &TC);
  while (TC--) {
    scanf("%d", &N);
    A[0] = A[1] = 0;
    ans = 0;
    vector<int> V;
    while (N--) {
      scanf("%s", S);
      for (j = 0; S[j]; j++) A[S[j] - '0']++;
      V.push_back(j);
    }
    sort(V.begin(), V.end());
    int p = A[0] / 2 + A[1] / 2, q = A[0] + A[1] - p * 2;
    int ans = 0;
    for (i = 0; i < V.size(); i++) {
      if (V[i] % 2) {
        if (q == 0) {
          if (p == 0) break;
          p--;
          q += 2;
        }
        if (V[i] - 1 > p * 2) break;
        q--;
        p -= (V[i] - 1) / 2;
      } else {
        if (V[i] > p * 2) break;
        p -= V[i] / 2;
      }
      ans++;
    }
    printf("%d\n", ans);
  }
}
