#include <bits/stdc++.h>
using namespace std;
long long BSDK() {
  int n, j, k, gos = 0, gs = 0, c, bs;
  string s;
  scanf("%d", &n);
  for (j = 0; j < n; j++) {
    cin >> s;
    for (k = c = 0; k < s.length() / 2; k++) {
      c += (s[k] != s[s.length() - 1 - k]);
    }
    gos += (s.length() % 2), gs += !(c % 2);
  }
  bs = n - gos - gs;
  n -= (bs & !gos);
  return n;
}
int main() {
  int i, t;
  scanf("%d", &t);
  for (i = 0; i < t; i++) {
    printf("%lld\n", BSDK());
  }
  return 0;
}
