#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
string s[maxn];
int a[maxn];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> s[i];
    int ans = 0;
    for (char c = 'a'; c <= 'e'; ++c) {
      memset(a, 0, sizeof(a));
      for (int i = 0; i < n; ++i) {
        for (auto x : s[i]) {
          if (x == c)
            ++a[i];
          else
            --a[i];
        }
      }
      sort(a, a + n, greater<int>());
      int res = 0, num = 0, i = 0;
      while (i < n && res + a[i] > 0) {
        res += a[i];
        ++num;
        ++i;
      }
      ans = max(ans, num);
    }
    cout << ans << endl;
  }
}
