#include <bits/stdc++.h>
using namespace std;
int power(int x, unsigned int y, int res) {
  while (y > 0) {
    if (y & 1) res = res * x;
    res %= 1000000007;
    y = y >> 1;
    x = x * x;
    x %= 1000000007;
  }
  return res % 1000000007;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int qwe;
  cin >> qwe;
  while (qwe--) {
    int n;
    cin >> n;
    string s;
    int k0 = 0, k1 = 0;
    int sum = 0;
    int h = 0;
    vector<int> a(n);
    for (long long i = 0; i < n; i++) {
      cin >> s;
      for (long long j = 0; j < s.length(); j++) {
        if (s[j] == '0')
          k0++;
        else
          k1++;
      }
      h += s.length() % 2;
    }
    if (h == 0 && k1 % 2 == 1)
      cout << n - 1 << '\n';
    else
      cout << n << '\n';
  }
}
