#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int tot_len = 0, odd_strings = 0, zeros = 0, ones = 0;
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      int l = s.length();
      if (l % 2 != 0) odd_strings++;
      tot_len += l;
      for (int j = 0; j < l; j++) {
        if (s[j] == '0')
          zeros++;
        else
          ones++;
      }
    }
    if (odd_strings % 2 == 1) {
      if ((zeros % 2 == 0 && ones % 2 != 0) ||
          (zeros % 2 != 0 && ones % 2 == 0))
        cout << n << endl;
      else
        cout << n - 1 << endl;
    } else if (odd_strings != 0) {
      if ((zeros % 2 == 1 && ones % 2 == 1) ||
          (zeros % 2 == 0 && ones % 2 == 0))
        cout << n << endl;
      else
        cout << n - 1 << endl;
    } else if (odd_strings == 0) {
      if (ones % 2 == 0 && zeros % 2 == 0)
        cout << n << endl;
      else
        cout << n - 1 << endl;
    }
  }
  return 0;
}
