#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int MX = 3e5 + 7;
char str[MX];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    char str[55];
    int len;
    int cnt[2] = {0, 0};
    int ok = 0;
    for (int i = 0; i < n; ++i) {
      cin >> str;
      len = strlen(str);
      if (len & 1) ok = 1;
      for (int j = 0; str[j]; ++j) cnt[str[j] - '0']++;
    }
    if (!ok && cnt[0] & 1 && cnt[1] & 1) n--;
    cout << n << endl;
  }
}
