#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand(long long l, long long r) {
  uniform_int_distribution<long long> uid(l, r);
  return uid(rng);
}
const int mod = 1e9 + 7;
int pwr(int a, long long b) {
  int ans = 1;
  while (b) {
    if (b & 1) {
      ans = ((long long)ans * a) % mod;
    }
    a = ((long long)a * a) % mod;
    b >>= 1;
  }
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int cc = 0;
    int res = 0;
    for (int i = 1; i <= n; i++) {
      string s;
      cin >> s;
      int c = 0;
      for (int j = 0; j <= (int)s.size() / 2 - 1; j++) {
        if (s[j] != s[(int)s.size() - 1 - j]) c++;
      }
      if ((int)s.size() & 1) res++;
      if (c & 1) cc++;
    }
    cc &= 1;
    if (cc && res) cc = 0;
    cout << n - (cc & 1) << '\n';
  }
  return 0;
}
