#include <bits/stdc++.h>
using namespace std;
long long MODULE = 1000000007;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int strNum;
    cin >> strNum;
    int ones = 0, zeros = 0;
    int chet = 0, nechet = 0;
    for (int k = 0; k < strNum; k++) {
      string s;
      cin >> s;
      if (s.length() % 2 == 0)
        chet++;
      else
        nechet++;
      for (int j = 0; j < s.length(); j++) {
        if (s[j] == '0')
          zeros++;
        else
          ones++;
      }
    }
    if (nechet == 0) {
      if (ones % 2 == 1 && zeros % 2 == 1) {
        cout << strNum - 1 << endl;
        continue;
      } else {
        cout << strNum << endl;
        continue;
      }
    } else {
      cout << strNum << endl;
    }
  }
  return 0;
}
