#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;
const int maxn = 1e6 + 10;
int d[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
inline long long read() {
  long long s = 0, w = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (isdigit(ch)) s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
char s[1000];
int sz[1000];
int main() {
  int t;
  t = read();
  while (t--) {
    int ans = 0;
    int cnt1 = 0, cnt0 = 0;
    int n;
    n = read();
    for (int i = 1; i <= n; i++) {
      scanf("%s", s + 1);
      int len = strlen(s + 1);
      sz[i] = len;
      for (int j = 1; j <= len; j++)
        if (s[j] == '1')
          cnt1++;
        else
          cnt0++;
    }
    sort(sz + 1, sz + n + 1);
    for (int i = 1; i <= n; i++) {
      int tmp = (sz[i] / 2) * 2;
      if (cnt1 >= tmp) {
        ans++;
        cnt1 -= tmp;
      } else if (cnt0 >= tmp) {
        ans++;
        cnt0 -= tmp;
      } else {
        int qb1 = cnt1 / 2 * 2, qb0 = cnt0 / 2 * 2;
        if (qb1 + qb0 >= tmp) {
          cnt1 -= qb1;
          cnt0 -= tmp - qb1;
          ans++;
        } else
          continue;
      }
      if (sz[i] % 2 == 1) {
        if (cnt1 % 2 == 1) {
          cnt1--;
        } else if (cnt0 % 2 == 1)
          cnt0--;
        else if (cnt1 >= 1)
          cnt1--;
        else if (cnt0 >= 1)
          cnt0--;
        else
          ans--;
      }
    }
    write(ans);
    puts("");
  }
  return 0;
}
