#include <bits/stdc++.h>
using namespace std;
const int maxn = 106 + 10;
int cas;
string str;
int a1[maxn], a2[maxn];
bool vis1[maxn], vis2[maxn];
int n;
int main() {
  cin >> cas;
  while (cas--) {
    memset(a1, 0, sizeof a1);
    memset(a2, 0, sizeof a2);
    memset(vis1, 0, sizeof vis1);
    memset(vis2, 0, sizeof vis2);
    int s0 = 0, s1 = 0;
    int olen = 0, elen = 0;
    int cnt1 = 0, cnt2 = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> str;
      for (int i = 0; i < str.size(); i++) {
        if (str[i] == '1')
          s0++;
        else
          s1++;
      }
      if (str.size() & 1)
        olen++, a1[++cnt1] = str.size();
      else
        elen++, a2[++cnt2] = str.size();
    }
    int ans = 0;
    sort(a1 + 1, a1 + 1 + cnt1);
    sort(a2 + 1, a2 + 1 + cnt2);
    if ((s0 % 2 == 1 || s1 % 2 == 1) && (olen == 0)) {
      cout << n - 1 << endl;
    } else {
      cout << n << endl;
    }
  }
  return 0;
}
