#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n;
    string str;
    scanf("%d", &n);
    int sum0 = 0, sum1 = 0;
    int sum = 0;
    for (int j = 0; j < n; j++) {
      cin >> str;
      if (str.size() & 1) sum++;
      for (int i = 0; str[i]; i++) {
        if (str[i] == '0')
          sum0++;
        else
          sum1++;
      }
    }
    if (sum > 0)
      cout << n << endl;
    else if (sum0 % 2 == 0 && sum1 % 2 == 0)
      cout << n << endl;
    else
      cout << n - 1 << endl;
  }
  return 0;
}
