#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  scanf("%d", &n);
  vector<int> v[5];
  for (int i = 0; i < n; i++) {
    char c[400005];
    scanf("%s", c);
    int cnt[5] = {0, 0, 0, 0, 0};
    for (int j = 0; c[j] != 0; j++) {
      cnt[c[j] - 'a']++;
    }
    int n = strlen(c);
    for (int j = 0; j < 5; j++) {
      v[j].push_back(2 * cnt[j] - n);
    }
  }
  int ans = 0;
  for (int i = 0; i < 5; i++) {
    sort(v[i].begin(), v[i].end());
    reverse(v[i].begin(), v[i].end());
    int tot = 0, sum = 0;
    int fi = 1;
    for (auto it : v[i]) {
      if (tot + it <= 0 && !fi) {
        break;
      }
      fi = 0;
      tot += it;
      if (tot > 0) sum++;
    }
    ans = max(ans, sum);
  }
  printf("%d\n", ans);
}
int main() {
  int t = 1;
  scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}
