#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5, mod = 1e9 + 7, lmt = 31;
long long solve() {
  long long n;
  cin >> n;
  vector<string> arr(n);
  long long ans = 0;
  for (string &x : arr) cin >> x;
  for (char x = 'a'; x <= 'e'; x++) {
    vector<long long> diff(n, 0);
    for (long long i = 0; i < n; i++) {
      diff[i] = 0;
      for (char &c : arr[i]) diff[i] += (c == x);
      diff[i] = 2 * diff[i] - ((long long)(arr[i]).size());
    }
    sort((diff).rbegin(), (diff).rend());
    long long cnt = 0, sum = 0;
    for (long long &x : diff) {
      if (sum + x <= 0) break;
      cnt++;
      sum += x;
    }
    ans = max(ans, cnt);
  }
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long T = 1;
  cin >> T;
  for (long long i = 1; i <= T; i++) {
    cout << solve() << '\n';
  }
}
