#include <bits/stdc++.h>
using namespace std;
int n, d[60], cnt[60], i, dem, t;
string s[60];
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    dem = 0;
    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i <= n; i++) {
      cin >> s[i];
      for (int j = 0; j < s[i].size(); j++) cnt[s[i][j] - '0']++;
      if (s[i].size() % 2 == 1) dem++;
    }
    if (dem % 2 == 1 && (abs(cnt[0] - cnt[1])) % 2 == 1)
      cout << n << endl;
    else if (dem % 2 == 1)
      cout << n - 1 << endl;
    else if (dem % 2 == 0 && dem > 0 && cnt[1] % 2 == 1 && cnt[0] % 2 == 1)
      cout << n << endl;
    else if (dem % 2 == 0 && dem == 0 && cnt[1] % 2 == 1 && cnt[0] % 2 == 1)
      cout << n - 1 << endl;
    else if (dem % 2 == 0 && abs(cnt[1] - cnt[0]) % 2 == 0)
      cout << n << endl;
    else
      cout << n - 1 << endl;
  }
}
