#include <bits/stdc++.h>
using namespace std;
int fx[] = {0, 1, 1, 1, 0, -1, -1, -1};
int fy[] = {1, 1, 0, -1, -1, -1, 0, 1};
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    vector<string> data(n);
    for (int i = 0; i < n; i++) cin >> data[i];
    vector<int> cnt1, cnt2;
    for (int i = 0; i < n; i++) {
      int o = 0, k = 0;
      for (auto j : data[i]) {
        if (j == '0')
          o++;
        else
          k++;
      }
      cnt1.push_back(o);
      cnt2.push_back(k);
    }
    int ans = 0;
    unordered_map<int, bool> mp;
    for (int i = 0; i < n; i++) {
      int tmp = cnt1[i] + cnt2[i];
      if (tmp % 2 == 0) {
        if (cnt1[i] % 2 == 0 && cnt2[i] % 2 == 0) {
          ans++;
          mp[i] = true;
          continue;
        } else {
          if (cnt1[i] < cnt2[i]) {
            for (int j = 0; j < n; j++) {
              if (mp[j] || i == j) continue;
              if (cnt1[j] >= 1) {
                cnt1[j]--;
                cnt2[j]++;
                ans++;
                mp[i] = true;
                break;
              }
            }
          } else {
            for (int j = 0; j < n; j++) {
              if (mp[j] || i == j) continue;
              if (cnt2[j] >= 1) {
                cnt2[j]--;
                cnt1[j]++;
                ans++;
                mp[i] = true;
                break;
              }
            }
          }
        }
      }
    }
    for (int i = 0; i < n; i++) {
      if (mp[i]) continue;
      int tmp = cnt1[i] + cnt2[i];
      if (tmp % 2 != 0) ans++;
    }
    printf("%d", ans);
    printf("\n");
  }
  return 0;
}
