#include <bits/stdc++.h>
using namespace std;
int cnt[2];
int len[1005];
char str[1005];
int main() {
  int tc;
  scanf("%d", &tc);
  while (tc--) {
    int n;
    scanf("%d", &n);
    cnt[0] = cnt[1] = 0;
    for (int i = 0; i < n; i++) {
      scanf("%s", str);
      len[i] = strlen(str);
      for (int j = 0; j < len[i]; j++) {
        cnt[str[j] - '0']++;
      }
    }
    int ans = 0;
    sort(len, len + n);
    for (int i = 0; i < n; i++) {
      if (len[i] % 2) {
        if (cnt[0] % 2) {
          if ((cnt[0] - 1) / 2 * 2 + cnt[1] / 2 * 2 >= len[i] - 1) {
            cnt[0]--;
            int red = min((len[i] - 1) / 2 * 2, cnt[0] / 2 * 2);
            cnt[0] -= red;
            red = len[i] - 1 - red;
            cnt[1] -= red;
            ans++;
          }
        } else if (cnt[1] % 2) {
          if ((cnt[1] - 1) / 2 * 2 + cnt[0] / 2 * 2 >= len[i] - 1) {
            cnt[1]--;
            int red = min((len[i] - 1) / 2 * 2, cnt[1] / 2 * 2);
            cnt[1] -= red;
            red = len[i] - 1 - red;
            cnt[0] -= red;
            ans++;
          }
        } else {
          if (cnt[0] / 2 * 2 + cnt[1] / 2 * 2 >= len[i]) {
            cnt[0]--;
            int red = min((len[i] - 1) / 2 * 2, cnt[0] / 2 * 2);
            cnt[0] -= red;
            red = len[i] - 1 - red;
            cnt[1] -= red;
            ans++;
          }
        }
      } else {
        if (cnt[0] / 2 * 2 + cnt[1] / 2 * 2 >= len[i]) {
          int red = min(len[i] / 2 * 2, cnt[0] / 2 * 2);
          cnt[0] -= red;
          red = len[i] - red;
          cnt[1] -= red;
          ans++;
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
