why_cant_you_take_inputs_while_printing_in_pycharm_it_is_so_annoying = [[input() for i in range(int(input()))] for _ in range(int(input()))]
for words in why_cant_you_take_inputs_while_printing_in_pycharm_it_is_so_annoying:
maxes = []
for letter in 'abcde':
vals = sorted([2 * i.count(letter) - len(i) for i in words])[::-1]
pi = ''
storyL = 0
storyB = 0
for i in vals:
if storyB + i > 0:
storyB += i
storyL += 1
maxes.append(storyL)
print(max(maxes))
#include "bits/stdc++.h"
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> oset;
#define int long long
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef queue<int> qi;
typedef set<int> si;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef priority_queue<int,std::vector<int>,greater<int>> min_prior;
typedef priority_queue<int> prior;
#define fori(i,n) for(int i = 0; i < n; i++)
#define rfori(i,n) for(int i = n; i >=0; i--)
#define fora(i,a,b) for(int i = a; i <= b; i++)
#define rfora(i,a,b) for(int i = a; i >= b; i--)
#define each(a,x) for(auto a: x)
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define MOD 1000000007
#define MOD1 998244353
#define fill(str,a) memset(str, a, sizeof(str));
#define INF 1e18
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define PI 3.141592653589793238462
#define all(x) (x).begin(), (x).end()
#define pos(v,a) find(all(v),a) - v.begin()
#define sz(v) (int)v.size()
#define sortva(v) sort(all(v))
#define sortvd(v) sort(v.rbegin(),v.rend())
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define maxind(v) max_element(all(v)) - v.begin()
#define minind(v) min_element(all(v)) - v.begin()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define int_max 2147483647
#define int_min -2147483647
#define isthere(v,n) (find(all(v),n)!=v.end())
#define delv(v,n) v.erase(find(all(v),n))
#ifndef ONLINE_JUDGE
#include "judge.h"
#else
#define dbg(x)
void init(void){}
#endif
int val(char cot, std::vector<string>& s){
vi v;
for(string temp: s){
vi vun(5,0);
for(char c: temp){vun[c-'a']++;}
v.push_back(vun[cot-'a'] - sz(temp) + vun[cot-'a']);
}
sortvd(v);
int ans = 0,sum = 0;
for(int i: v){
if(sum + i > 0){sum+=i;ans++;}
else{break;}
}
return ans;
}
void fun(){
int n;string temp;std::cin >> n;
std::vector<string> s;
fori(i,n){
std::cin >> temp;
s.push_back(temp);
}
int ans = 0;
for (int i = 0; i < 5; ++i){
ans = max(ans,val( (char)(i + 'a'),s));
}
std::cout << ans << "\n";
}
int32_t main(){
ios:: sync_with_stdio(0),cin.tie(0);cout<<fixed<<setprecision(20);init();int t = 1;
std::cin >> t;
while(t--)
fun();
return 0;
}
/*
*/
202A - LLPS | 978A - Remove Duplicates |
1304A - Two Rabbits | 225A - Dice Tower |
1660D - Maximum Product Strikes Back | 1513A - Array and Peaks |
1251B - Binary Palindromes | 768B - Code For 1 |
363B - Fence | 991B - Getting an A |
246A - Buggy Sorting | 884A - Book Reading |
1180A - Alex and a Rhombus | 445A - DZY Loves Chessboard |
1372A - Omkar and Completion | 159D - Palindrome pairs |
981B - Businessmen Problems | 1668A - Direction Change |
1667B - Optimal Partition | 1668B - Social Distance |
88B - Keyboard | 580B - Kefa and Company |
960A - Check the string | 1220A - Cards |
897A - Scarborough Fair | 1433B - Yet Another Bookshelf |
1283B - Candies Division | 1451B - Non-Substring Subsequence |
1408B - Arrays Sum | 1430A - Number of Apartments |