#include <bits/stdc++.h>
using namespace std;
long long pw(long long a, long long b) {
  if (b == 0) return 1;
  if (b % 2 == 1)
    return (a * pw((a * a) % 1000000007, b / 2)) % 1000000007;
  else
    return (1 * pw((a * a) % 1000000007, b / 2)) % 1000000007;
}
void solve() {
  int n;
  cin >> n;
  int c0 = 0, c1 = 0, o = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int x = s.size();
    if (x % 2) o++;
    for (int i = 0; i < x; i++) {
      if (s[i] == '1')
        c1++;
      else
        c0++;
    }
  }
  if (o % 2) {
    if (c0 % 2 != c1 % 2)
      cout << n << endl;
    else
      cout << n - 1 << endl;
  } else {
    if (c0 % 2 == c1 % 2) {
      if (o > 0)
        cout << n << endl;
      else if (c0 % 2 == 0)
        cout << n << endl;
      else
        cout << n - 1 << endl;
    } else
      cout << n - 1 << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
