#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string ch[n + 1];
    int zero = 0, one = 0;
    vector<int> arr;
    for (int i = 0; i < n; i++) {
      cin >> ch[i];
      arr.push_back(ch[i].size());
      for (int j = 0; j < ch[i].size(); j++) {
        if (ch[i][j] == '0')
          zero++;
        else
          one++;
      }
    }
    sort(arr.begin(), arr.end());
    int cnt = 0;
    for (int i = 0; i < arr.size(); i++) {
      int len = 0;
      int tmp = arr[i];
      if (arr[i] % 2) tmp--;
      while (len < tmp) {
        if (zero >= 2) {
          len += 2;
          zero -= 2;
        } else if (one >= 2) {
          len += 2;
          one -= 2;
        } else {
          break;
        }
      }
      if (len == tmp && len < arr[i]) {
        if (zero % 2 == 1) {
          len++;
          zero--;
        } else if (one % 2) {
          len++;
          one--;
        } else {
          if (zero > 0) {
            len++;
            zero--;
          } else if (one > 0) {
            len++;
            one--;
          }
        }
      }
      if (len == arr[i]) {
        cnt++;
      }
    }
    cout << cnt << "\n";
  }
  return 0;
}
