#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rnd(long long l, long long r) { return l + rng() % (r - l + 1); }
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
const long long N = 2e5 + 10;
long long cnt[N][5], f[N], len[N], n;
long long calc(long long j) {
  for (long long i = 1, _c = n; i <= _c; ++i) f[i] = 2 * cnt[i][j] - len[i];
  sort(f + 1, f + n + 1, greater<long long>());
  long long sum = 0;
  for (long long i = 1, _c = n; i <= _c; ++i) {
    sum += f[i];
    if (sum <= 0) return i - 1;
  }
  return n;
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (long long i = 1, _c = n; i <= _c; ++i) {
      string s;
      cin >> s;
      len[i] = s.size();
      for (long long j = 0, _c = 4; j <= _c; ++j) cnt[i][j] = 0;
      for (long long j = 0, _c = s.size() - 1; j <= _c; ++j)
        cnt[i][s[j] - 'a']++;
    }
    long long res = 0;
    for (long long i = 0, _c = 4; i <= _c; ++i) {
      bool ok = false;
      for (long long j = 1, _c = n; j <= _c; ++j) f[j] = 2 * cnt[j][i] - len[j];
      sort(f + 1, f + n + 1);
      long long sum = 0;
      for (long long j = 0, _c = 4; j <= _c; ++j) res = max(res, calc(j));
    }
    cout << res << "\n";
  }
}
