#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int total = 0;
  vector<int> data[5];
  for (int i = 0; i < n; i = i + 1) {
    string temp;
    cin >> temp;
    for (int j = 0; j < 5; j++) data[j].push_back(-temp.length());
    total += temp.length();
    for (int j = 0; j < temp.length(); j++) {
      data[temp.at(j) - 'a'].back() += 2;
    }
  }
  int result = 0;
  for (int i = 0; i < 5; i = i + 1) {
    sort(data[i].begin(), data[i].end(),
         [&](const int &x, const int &y) { return x > y; });
    int current_result = 0;
    int current_total = 0;
    for (int j = 0; j < n; j++) {
      if (data[i][j] > 0 || current_total > 0) {
        current_result++;
        current_total += data[i][j];
      }
    }
    if (current_total <= 0) current_result--;
    result = max(result, current_result);
  }
  cout << result << "\n";
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
