#include <bits/stdc++.h>
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
void solve() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    bool flag = false;
    int one = 0, zero = 0;
    vector<string> s(n);
    int sz = 0;
    for (int i = (int)0; i < (int)n; ++i) {
      cin >> s[i];
      if (s[i].size() % 2) flag = true;
      for (int j = (int)0; j < (int)s[i].size(); ++j) {
        if (s[i][j] == '1')
          ++one;
        else
          ++zero;
      }
    }
    if (!flag && one % 2 != 0 && zero % 2 != 0)
      cout << n - 1 << "\n";
    else
      cout << n << "\n";
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  solve();
  return 0;
}
