#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = 0;
    int re = 0;
    int need = 0;
    for (int i = 0; i < n; i++) {
      if (a[i].size() % 2 == 1) {
        ans += 1;
        re++;
      } else {
        int cnt1 = 0, cnt0 = 0;
        for (int j = 0; j < a[i].size(); j++) {
          if (a[i][j] == '1')
            cnt1++;
          else
            cnt0++;
        }
        if (cnt1 % 2 == 0 && cnt0 % 2 == 0)
          ans++;
        else {
          need++;
        }
      }
    }
    if (need % 2 == 0)
      ans += need;
    else {
      ans += need - 1;
      if (re > 0) ans++;
    }
    cout << ans << endl;
  }
}
