#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 7;
const long long INF = (long long)1e18 + 7;
const int N = 200007;
bool c;
int chkp(string x) {
  int ans = 0;
  if ((int)x.size() % 2) c = 1;
  for (int i = 0, j = (int)x.size() - 1; i < j; i++, j--) {
    if (x[i] == x[j]) continue;
    ans++;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int q;
  cin >> q;
  while (q--) {
    int n, sol = 0;
    cin >> n;
    c = 0;
    for (int i = 0; i < n; i++) {
      string x;
      cin >> x;
      sol += chkp(x);
    }
    if (sol % 2 == 0 || c == 1)
      cout << n << '\n';
    else
      cout << n - 1 << '\n';
  }
  return 0;
}
