#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  for (int z = 0; z < q; z++) {
    int m;
    cin >> m;
    int ev = 0, od = 0;
    int arr1[50] = {0}, arr0[50] = {0};
    int evod[50] = {-1};
    string s[50];
    for (int i = 0; i < m; i++) cin >> s[i];
    int count0 = 0, count1 = 0;
    for (int i = 0; i < m; i++) {
      int j = 0;
      while (s[i][j] != '\0') {
        if (s[i][j] == '0') {
          count0++;
          arr0[i]++;
        } else {
          count1++;
          arr1[i]++;
        }
        j++;
      }
      if (j % 2 == 0) {
        ev++;
        evod[i] = 0;
      } else {
        od++;
        evod[i] = 1;
      }
    }
    int ans = 0;
    int r = od;
    if (ev == m) {
      if (count0 % 2 == 0 && count1 % 2 == 0)
        cout << m << "\n";
      else
        cout << m - 1 << "\n";
    } else {
      int k = 0;
      int ans = 0;
      for (k = 0; k < m; k++) {
        if (arr1[k] % 2 == 0 && arr0[k] % 2 == 0 &&
            (arr0[k] + arr1[k]) % 2 == 0)
          ans++;
        else if ((arr0[k] + arr1[k]) % 2 == 0) {
          if (od > 0) {
            ans++;
          }
        }
      }
      cout << ans + r << "\n";
    }
  }
}
