#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> one(n), zero(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < s[i].size(); j++) {
      if (s[i][j] == '1')
        one[i]++;
      else
        zero[i]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (one[i] % 2 != 0 && zero[i] % 2 != 0) {
      for (int j = 0; j < n; j++) {
        if (j == i) continue;
        if (one[j] % 2 != 0 && zero[j] % 2 != 0) {
          ans++;
          one[j]--;
          zero[j]++;
          one[i]++;
          zero[i]--;
          break;
        } else if (one[j] % 2 != 0 && zero[j] % 2 == 0) {
          ans++;
          one[j]--;
          zero[j]++;
          one[i]++;
          zero[i]--;
          break;
        } else if (one[j] % 2 == 0 && zero[j] % 2 != 0) {
          ans++;
          one[j]++;
          zero[j]--;
          one[i]--;
          zero[i]++;
          break;
        }
      }
    } else {
      ans++;
    }
  }
  cout << ans << "\n";
}
int main() {
  int t = 1;
  cin >> t;
  while (t--) solve();
}
