#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T gi() {
  T f = 1, x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return f * x;
}
const int INF = 0x3f3f3f3f, N = 53, M = N << 1;
int T;
int n;
int a[N];
char s[N];
bool ok[N];
int main() {
  T = gi<int>();
  while (T--) {
    n = gi<int>();
    int c0 = 0, c1 = 0;
    for (int i = 1; i <= n; i += 1) {
      scanf("%s", s);
      a[i] = strlen(s);
      for (int j = 0; j < strlen(s); j += 1)
        if (s[j] == '0')
          ++c0;
        else
          ++c1;
    }
    sort(a + 1, a + 1 + n);
    int ans = 0;
    for (int i = 1; i <= n; i += 1)
      if (a[i] % 2 == 0) {
        if (c0 < c1) swap(c0, c1);
        if (c0 > a[i])
          c0 -= a[i], ++ans;
        else if (c0 % 2 == 0)
          c0 = 0, c1 -= s[i] - c0, ++ans;
        else if (c0 % 2 == 1 && c1 >= a[i] - c0 + 1)
          c0 = 1, c1 -= a[i] - c0 + 1, ++ans;
      }
    for (int i = 1; i <= n; i += 1)
      if (a[i] & 1) {
        if (c0 < c1) swap(c0, c1);
        if (c0 > a[i])
          c0 -= a[i], ++ans;
        else if (c0 % 2 == 0 && c1 > a[i] - c0 + 1)
          c0 = 1, c1 -= a[i] - c0 + 1, ++ans;
        else
          c0 = 0, c1 -= a[i] - c0, ++ans;
      }
    cout << ans << endl;
  }
  return 0;
}
