#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    bool f = false;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
      string s;
      cin >> s;
      if (s.length() & 1) f = 1;
      for (int j = 0; j < s.length(); j++)
        if (s[j] == '0') cnt++;
    }
    if (cnt % 2 == 0 || f)
      cout << n << endl;
    else
      cout << n - 1 << endl;
  }
}
