#include <bits/stdc++.h>
using namespace std;
char a[1005];
vector<int> dat;
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    dat.clear();
    int n;
    scanf("%d", &n);
    int x = 0, y = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%s", a);
      int len = (int)strlen(a);
      if (len % 2 == 1) {
        dat.push_back(len);
      } else
        dat.push_back(len);
      for (int i = 0; i < len; i++) {
        if (a[i] == '0')
          x++;
        else
          y++;
      }
    }
    sort(dat.begin(), dat.end());
    int ans = 0;
    for (int i = 0; i < dat.size(); i++) {
      int now = dat[i];
      if (now % 2 == 1) {
        now--;
        if (x % 2 == 1)
          x--;
        else if (y % 2 == 1)
          y--;
      }
      if (x >= now) {
        x -= now;
        ans++;
      } else if (y >= now) {
        y -= now;
        ans++;
      } else if (x >= y) {
        if (y % 2 == 1) {
          if (x >= now - y + 1) {
            now -= y;
            now++;
            y = 1;
            x -= now;
            ans++;
          }
        } else {
          if (x >= now - y) {
            now -= y;
            y = 0;
            x -= now;
            ans++;
          }
        }
      } else {
        if (x % 2 == 1) {
          if (y >= now - x + 1) {
            now -= x;
            now++;
            x = 1;
            y -= now;
            ans++;
          }
        } else {
          if (y >= now - x) {
            now -= x;
            x = 0;
            y -= now;
            ans++;
          }
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
