#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void solve() {
  long long int n;
  cin >> n;
  long long int *arr = new long long int[n];
  string second;
  long long int zcount = 0, onecount = 0, odd = 0, even = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> second;
    arr[i] = second.length();
    if (arr[i] % 2)
      odd++;
    else
      even++;
    for (long long int j = 0; j < arr[i]; j++)
      if (second[j] == '0')
        zcount++;
      else
        onecount++;
  }
  sort(arr, arr + n);
  long long int count1 = 0;
  for (long long int i = 0; i < n; i++) {
    if (arr[i] % 2) {
      if (zcount % 2)
        zcount--;
      else if (onecount % 2)
        onecount--;
      else {
        if (zcount > 0)
          zcount--;
        else if (onecount > 0)
          onecount--;
      }
      arr[i]--;
    }
    long long int p = arr[i] / 2;
    if ((zcount / 2) + (onecount / 2) >= p) {
      if ((zcount / 2) >= p) {
        count1++;
        zcount -= 2 * p;
        continue;
      } else {
        p -= (zcount / 2);
        zcount -= (zcount / 2) * 2;
      }
      if ((onecount / 2) >= p) {
        count1++;
        onecount -= 2 * p;
        continue;
      }
    }
    if (p == 0) count1++;
  }
  cout << count1 << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
