#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y) {
  if (y == 0)
    return 1;
  else {
    long long result = power(x, y / 2) % 1000000007;
    if (y % 2 == 0)
      return (result % 1000000007 * result % 1000000007) % 1000000007;
    else
      return (result % 1000000007 * result % 1000000007 * x % 1000000007) %
             1000000007;
  }
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
void solve() {
  long long n;
  cin >> n;
  vector<string> v;
  for (long long i = 0; i < n; i++) {
    string s;
    cin >> s;
    v.push_back(s);
  }
  char c = 'a';
  vector<long long> ans;
  for (c = 'a'; c <= 'e'; c++) {
    vector<long long> freq;
    long long max_freq = 0;
    long long other_freq = 0;
    for (long long i = 0; i < v.size(); i++) {
      max_freq = 0;
      other_freq = 0;
      for (long long j = 0; j < v[i].size(); j++) {
        if (v[i][j] == c)
          max_freq++;
        else
          other_freq++;
      }
      freq.push_back(max_freq - other_freq);
    }
    sort(freq.rbegin(), freq.rend());
    if (freq[0] < 0) {
      ans.push_back(0);
      continue;
    }
    long long sum = 0;
    long long ind = 0;
    for (long long i = 0; i < freq.size(); i++) {
      sum = sum + freq[i];
      if (sum <= 0) {
        break;
      }
      ind = i + 1;
    }
    ans.push_back(ind);
    freq.clear();
  }
  cout << *max_element(ans.begin(), ans.end()) << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
