#include <bits/stdc++.h>
using namespace std;
template <typename T>
T mymax(T a, T b) {
  return (a > b) ? a : b;
}
template <typename T>
T mymin(T a, T b) {
  return (a < b) ? a : b;
}
template <typename T>
T myabs(T a) {
  return (a < 0) ? (-1 * a) : a;
}
template <typename T>
T mysqrt(T x) {
  if (x == 0 | x == 1) return x;
  int start = 1, End = x, ans;
  while (start <= End) {
    int mid = (start + End) / 2;
    if (mid * mid == x) return mid;
    if (mid * mid < x) {
      start = mid + 1;
      ans = mid;
    } else
      End = mid - 1;
  }
  return ans;
}
void fastIO() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
}
long long A[500006];
long long B[500006];
long long C[500006];
vector<long long> Ans;
vector<pair<long long, long long> > VP;
map<long long, long long> M;
vector<long long> prime;
bool mark[10000008];
long long N = 1e7;
void seive() {
  int limit = sqrt(N * 1.0) + 2;
  mark[1] = 1;
  for (int i = 4; i <= N; i += 2) mark[i] = 1;
  prime.push_back(2);
  for (int i = 3; i <= N; i += 2) {
    if (!mark[i]) {
      prime.push_back(i);
      if (i <= limit) {
        for (int j = i * i; j <= N; j += i * 2) mark[j] = 1;
      }
    }
  }
}
int main() {
  fastIO();
  long long a, b, c, n, m, k, p, q, r;
  long long cnt = 0, cntr = 0, sum = 0, ans = 1, check = 0;
  float x, y, z;
  long long Max = 0, Max1 = -1e18 + 1;
  long long Min = 1e18;
  string s, s1, s3, s4;
  cin >> n;
  while (n--) {
    cin >> m;
    long long zero = 0;
    long long one = 0;
    vector<long long> V;
    check = 0;
    for (int i = 0; i < m; i++) {
      cin >> s;
      for (int j = 0; j < s.size(); j++) {
        if (s[j] == '0')
          zero++;
        else
          one++;
      }
      if (s.size() % 2 == 1) check = 1;
      V.push_back(s.size());
    }
    if (zero % 2 != 0 && one % 2 != 0 && check == 0)
      cout << m - 1 << endl;
    else
      cout << m << endl;
  }
  return 0;
}
