#include <bits/stdc++.h>
using namespace std;
struct point {
  int x, y;
  int operator-(point &other) { return abs(x - other.x) + abs(y - other.y); }
};
const int MAXN = 1e3;
int lengths[MAXN];
int parents[MAXN];
struct edge {
  int v, to, cost;
  bool operator<(edge b) const { return cost < b.cost; }
};
void init() {
  memset(lengths, 1, MAXN);
  for (int i = 0; i < MAXN; i++) {
    parents[i] = i;
  }
}
int getParent(int p) {
  return parents[p] == p ? p : parents[p] = getParent(parents[p]);
}
void solve() {
  int n;
  cin >> n;
  int result = 0;
  int c[2] = {0, 0};
  bool hasM = false;
  for (int i = 0; i < n; i++) {
    string line;
    cin >> line;
    if (line.size() % 2 == 1) hasM = true;
    for (auto u : line) {
      c[u - '0']++;
    }
  }
  if (hasM || c[0] % 2 == 0) {
    cout << n << '\n';
  } else {
    cout << n - 1 << '\n';
  }
}
void print_input(string inputFile) {
  freopen(inputFile.c_str(), "r", stdin);
  string line;
  cout << "Input for " << inputFile << '\n';
  while (getline(cin, line)) {
    cout << line << '\n';
  }
  cout << "End of input\n";
}
int main() {
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) solve();
}
