#include <bits/stdc++.h>
using namespace std;
long long t, n, a[500009], x, y, z, w, ans;
string second[500009];
bool ok = false;
int main() {
  ios::sync_with_stdio(0);
  cin >> t;
  while (t--) {
    cin >> n;
    x = y = ans = 0;
    for (int i = 1; i <= n; i++) {
      cin >> second[i];
      a[i] = second[i].size() % 2;
      if (second[i].size() % 2 == 0) ok = true;
    }
    sort(a + 1, a + 1 + n);
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < second[i].size(); j++) {
        if (second[i][j] == '1')
          x++;
        else
          y++;
      }
    }
    x = x % 2;
    y = y % 2;
    w = 0;
    for (int i = 1; i <= n; i++) {
      if (a[i] == 1) {
        if (x == 1)
          x = 0;
        else if (y == 1)
          y = 0;
        else
          x = 1;
      }
    }
    ans = n;
    if (x + y != 0) ans--;
    cout << ans << endl;
  }
  return 0;
}
