#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string str;
    long long res = 0, r = 0;
    for (long long i = 0; i < n; i++) {
      cin >> str;
      long long x = 0, y = 0;
      for (long long j = 0; j < str.size(); j++) {
        if (str[j] == '0')
          x++;
        else
          y++;
      }
      if (x % 2 != 0 || y % 2 != 0) res++;
      if (x & 1 && y & 1) r++;
    }
    if (r % 2 == 0)
      cout << n;
    else if (res - r > 0)
      cout << n;
    else
      cout << n - 1;
    cout << "\n";
  }
}
