#include <bits/stdc++.h>
using namespace std;
struct strr {
  string s;
  int len;
} str[55];
bool cmp(struct strr a, struct strr b) { return a.len < b.len; }
int ans[55], t;
int num0, num1, num, dd, ss;
void work() {
  int n;
  int count = 0;
  num0 = 0;
  num1 = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> str[i].s;
    str[i].len = str[i].s.length();
    for (int j = 0; j < str[i].len; j++) {
      if (str[i].s[j] == '1') num1++;
      if (str[i].s[j] == '0') num0++;
    }
  }
  dd = num0 / 2 + num1 / 2;
  ss = num0 % 2 + num1 % 2;
  sort(str + 1, str + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    if (str[i].len % 2 == 0) {
      if ((str[i].len / 2) <= dd) {
        count = count + 1;
        dd -= str[i].len / 2;
      } else
        break;
    } else {
      if (ss == 0 && dd > 0) {
        ss = ss + 2;
        dd--;
      }
      if ((str[i].len / 2) <= dd) {
        ss--;
        dd -= str[i].len / 2;
        count = count + 1;
      } else
        break;
    }
  }
  ans[t] = count;
}
int main() {
  int q;
  cin >> q;
  for (t = 1; t <= q; t++) {
    work();
  }
  for (int i = 1; i <= q; i++) cout << ans[i] << endl;
  return 0;
}
