#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, ans = 0;
  cin >> n;
  vector<int> v[5];
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int cn = s.size(), cntr[5] = {0};
    for (int j = 0; j < cn; j++) cntr[s[j] - 'a']++;
    for (int j = 0; j < 5; j++) v[j].push_back(2 * cntr[j] - cn);
  }
  for (int i = 0; i < 5; i++) {
    sort(v[i].begin(), v[i].end(), greater<int>());
    int cur = 0, count = 0;
    for (int j = 0; j < n; j++) {
      cur += v[i][j];
      if (cur <= 0) break;
      count++;
    }
    ans = max(ans, count);
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int q;
  cin >> q;
  while (q--) {
    solve();
  }
  return 0;
}
