#include <bits/stdc++.h>
using namespace std;
int n;
char a[55][55];
void solve() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  int b0, b1, ret;
  b0 = b1 = ret = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < strlen(a[i]); ++j) {
      if (a[i][j] == '0')
        b0++;
      else
        b1++;
      ret += strlen(a[i]) & 1;
    }
  if (ret >= b0 % 2 + b1 % 2)
    cout << n;
  else
    cout << n - 1;
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
