#include <bits/stdc++.h>
using namespace std;
string s[400];
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    int cnt1 = 0, cnt0 = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < s[i].size(); j++) {
        if (s[i][j] == '0')
          cnt0++;
        else
          cnt1++;
      }
    }
    int ok = 0;
    if (cnt1 % 2 == 1) ok++;
    if (cnt0 % 2 == 1) ok++;
    int R = 0;
    for (int i = 0; i < n; i++) {
      int len = s[i].size();
      if (len % 2 == 1) R++;
    }
    if (R >= ok) {
      cout << n << endl;
    } else
      cout << n - 1 << endl;
  }
}
