#include <bits/stdc++.h>
const long long int INF = LLONG_MAX / 2;
const long long int N = 2e5 + 1;
using namespace std;
template <typename T>
void input(T &x) {
  cin >> x;
}
template <typename T>
void input(vector<T> &v, long long int n) {
  for (long long int i = 0; i < n; i++) {
    cin >> v[i];
  }
}
template <typename T>
void input(vector<vector<T>> &v, long long int m, long long int n) {
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      cin >> v[i][j];
    }
  }
}
template <typename T>
void print(vector<T> &v, string s = "array") {
  cout << s << " = ";
  for (T i : v) {
    cout << i << " ";
  }
  cout << endl;
}
template <typename T>
void print(vector<vector<T>> &v, string s = "matrix") {
  cout << s << " = \n";
  for (auto I : v) {
    for (T i : I) {
      cout << i << " ";
    }
    cout << endl;
  }
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return (a / gcd(a, b) * b);
}
bool compare(long long int i, long long int j) { return i > j; }
bool comp(pair<long long int, long long int> i,
          pair<long long int, long long int> j) {
  return i.first - i.second > j.first - j.second;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  std::cout << std::fixed;
  std::cout << std::setprecision(15);
  ;
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    vector<string> second(n);
    for (long long int i = 0; i < n; i++) {
      cin >> second[i];
    }
    std::vector<std::vector<long long>> hash(n, std::vector<long long>(5, 0));
    std::vector<long long> sum(n, 0);
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < second[i].size(); j++) {
        hash[i][second[i][j] - 97]++;
        sum[i]++;
      }
    }
    long long int ans = -INF;
    for (long long int i = 0; i < 5; i++) {
      long long int cnt_target = 0;
      long long int cnt_others = 0;
      std::vector<std::pair<long long, long long>> temp(n);
      for (long long int j = 0; j < n; j++) {
        for (long long int k = 0; k < 5; k++) {
          if (k == i) {
            cnt_target += hash[j][k];
          } else {
            cnt_others += hash[j][k];
          }
        }
        temp[j] = {hash[j][i], sum[j] - hash[j][i]};
      }
      sort(temp.begin(), temp.end(), comp);
      long long int k = 0;
      long long int t = 0, o = 0;
      while (k < n) {
        t += temp[k].first;
        o += temp[k].second;
        if (t <= o) {
          break;
        }
        k++;
      }
      ans = max(ans, k);
    }
    cout << ans << endl;
  }
}
