#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
void print(int* a, int n) {
  int i;
  for (i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
long long int arrMax(long long int* a, long long int n) {
  long long int i, max = a[0];
  for (i = 1; i < n; i++) {
    if (a[i] > max) max = a[i];
  }
  return max;
}
void print2d(int a[][100], int m, int n) {
  int i, j;
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      cout << setw(2) << a[i][j];
    }
    cout << endl;
  }
}
void fio() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
int main() {
  fio();
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s[n];
    int i;
    for (i = 0; i < n; i++) cin >> s[i];
    long long int sum1 = 0;
    long long int sum0 = 0;
    int j;
    vector<int> v;
    int flag = 0;
    for (i = 0; i < n; i++) {
      for (j = 0; j < s[i].size(); j++) {
        if (s[i][j] == '1')
          sum1++;
        else
          sum0++;
      }
      v.push_back(s[i].size());
      if (s[i].size() % 2 != 0) flag = 1;
    }
    sort(v.begin(), v.end());
    int ans1;
    long long sum11 = sum1;
    long long sum00 = sum0;
    for (i = 0; i < v.size(); i++) {
      if (sum1 - v[i] >= 0)
        sum1 -= v[i];
      else if (sum0 - v[i] >= 0)
        sum0 -= v[i];
      else
        break;
    }
    if (i == v.size()) {
      cout << n << endl;
      continue;
    }
    if (sum0 % 2 != 0 && sum1 % 2 != 0 && flag == 0) {
      ans1 = i;
    } else {
      cout << n << endl;
      continue;
    }
    sum0 = sum00;
    sum1 = sum11;
    for (i = 0; i < v.size(); i++) {
      if (sum0 - v[i] >= 0)
        sum0 -= v[i];
      else if (sum1 - v[i] >= 0)
        sum1 -= v[i];
      else
        break;
    }
    if (i == v.size()) {
      cout << n << endl;
      continue;
    }
    if (sum0 % 2 != 0 && sum1 % 2 != 0 && flag == 0) {
      cout << max(i, ans1) << endl;
    } else {
      cout << n << endl;
      continue;
    }
  }
}
