#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, ans1 = 0, ans = 0, one = 0, zero = 0, cnt = 0, x = 0;
    cin >> n;
    vector<string> s(n);
    for (long long int i = 0; i < n; i++) {
      cin >> s[i];
      if (s[i].length() % 2 != 0) {
        ans1++;
      }
    }
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < s[i].length(); j++) {
        if (s[i].length() % 2 == 0) {
          x = 1;
          if (s[i][j] == '1') {
            one++;
          } else {
            zero++;
          }
        }
      }
      if (x == 1) {
        if (one % 2 == 0 && zero % 2 == 0) {
          ans++;
        } else {
          cnt++;
        }
        one = 0, zero = 0;
        x = 0;
      }
    }
    if (ans1 > 0 && (cnt - (cnt / 2) * 2) != 0) {
      cout << ans1 + ans + (cnt / 2) * 2 + (min(ans1, (cnt - (cnt / 2) * 2)))
           << endl;
    } else {
      cout << ans1 + ans + (cnt / 2) * 2 << endl;
    }
  }
}
