#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int count = 0, wc = 0;
    bool flag = 0;
    int m = n;
    while (n--) {
      string s;
      cin >> s;
      int l = s.size();
      if (l % 2 == 1) flag = 1;
      int zeroc = 0, onec = 0;
      for (int i = 0; i < l; i++) {
        if (s[i] == '0') {
          zeroc++;
        } else {
          onec++;
        }
      }
      if (onec % 2 == 1 && zeroc % 2 == 1) {
        wc++;
      } else {
        count++;
      }
    }
    if (flag == 1)
      cout << m << endl;
    else {
      count = count + 2 * (wc / 2);
      cout << count << endl;
    }
  }
  return 0;
}
