#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long double PI = acosl(-1);
const int inf = 2e9 + 5;
const int nmax = 1e6 + 5;
const int MAXLG = log2(nmax) + 1;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tc;
  cin >> tc;
  while (tc--) {
    int n;
    cin >> n;
    int ek = 0, zer = 0;
    bool odase = false;
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      for (char ch : s)
        if (ch == '1')
          ek++;
        else
          zer++;
      if (s.size() % 2) odase = true;
    }
    if (!odase and ek & 1)
      cout << n - 1 << "\n";
    else
      cout << n << "\n";
  }
}
