#include <bits/stdc++.h>
using namespace std;
int q, n, len, mark[60];
string s[60];
int cnt[2], odd;
void count_10() {
  for (int i = 0; i < n; i++) {
    len = s[i].size();
    for (int j = 0; j < len; j++) cnt[s[i][j] - '0']++;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> q;
  while (q--) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      if (s[i].size() % 2 == 1) odd++;
    }
    count_10();
    if (cnt[0] % 2 == 1 && cnt[1] % 2 == 1 && odd == 0)
      cout << n - 1 << endl;
    else
      cout << n << endl;
    memset(cnt, 0, sizeof(cnt));
    odd = 0;
  }
  return 0;
}
