description: Stephen Queen wants to write a story. He is a very unusual writer, he uses only letters 'a', 'b', 'c', 'd' and 'e'!
  
  To compose a story, Stephen wrote out n words consisting of the first 5 lowercase letters of the Latin alphabet. He wants to select the maximum number of words to make an interesting story.
  
  Let a story be a sequence of words that are not necessarily different. A story is called interesting if there exists a letter which occurs among all words of the story more times than all other letters together.
  
  For example, the story consisting of three words "bac", "aaada", "e" is interesting (the letter 'a' occurs 5 times, all other letters occur 4 times in total). But the story consisting of two words "aba", "abcde" is not (no such letter that it occurs more than all other letters in total).
  
  You are given a sequence of n words consisting of letters 'a', 'b', 'c', 'd' and 'e'. Your task is to choose the maximum number of them to make an interesting story. If there's no way to make a non-empty story, output 0.
  
  Input
  
  The first line contains one integer t (1 ≤ t ≤ 5000) — the number of test cases. Then t test cases follow.
  
  The first line of each test case contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of the words in the sequence. Then n lines follow, each of them contains a word — a non-empty string consisting of lowercase letters of the Latin alphabet. The words in the sequence may be non-distinct (i. e. duplicates are allowed). Only the letters 'a', 'b', 'c', 'd' and 'e' may occur in the words.
  
  It is guaranteed that the sum of n over all test cases doesn't exceed 2 ⋅ 10^5; the sum of the lengths of all words over all test cases doesn't exceed 4 ⋅ 10^5.
  
  Output
  
  For each test case, output the maximum number of words that compose an interesting story. Print 0 if there's no way to make a non-empty interesting story.
  
  Example
  
  Input
  
  
  6
  3
  bac
  aaada
  e
  3
  aba
  abcde
  aba
  2
  baba
  baba
  4
  ab
  ab
  c
  bc
  5
  cbdca
  d
  a
  d
  e
  3
  b
  c
  ca
  
  
  Output
  
  
  3
  2
  0
  2
  3
  2
  
  Note
  
  In the first test case of the example, all 3 words can be used to make an interesting story. The interesting story is "bac aaada e".
  
  In the second test case of the example, the 1-st and the 3-rd words can be used to make an interesting story. The interesting story is "aba aba". Stephen can't use all three words at the same time.
  
  In the third test case of the example, Stephen can't make a non-empty interesting story. So the answer is 0.
  
  In the fourth test case of the example, Stephen can use the 3-rd and the 4-th words to make an interesting story. The interesting story is "c bc".
solution: import java.io.*;
  import java.util.*;
  public class d3prac implements Runnable 
  {
  	private boolean console=false;
  
  	class node
  	{
  		int tc; int dif[];
  		node(int tc,int dif[])
  		{
  			this.tc=tc; this.dif=dif;
  		}
  	}
  	public void solve() 
  	{
  		int i=0; int n=in.ni(); char a[][]=new char[n][]; node b[]=new node[n];
  		for(i=0;i<n;i++) a[i]=in.ns().toCharArray();
  		for(i=0;i<n;i++)
  		{
  			int len=a[i].length; int fr[]=new int[26];
  			for(int j=0;j<len;j++) fr[a[i][j]-'a']++;
  			int dif[]=new int[26];
  			for(int j=0;j<26;j++) dif[j]=2*fr[j]-len;
  			b[i]=new node(len,dif);
  		}
  		int ans=0;
  		for(i=0;i<26;i++)
  		{
  			int g=i; Arrays.sort(b, (d,q)-> q.dif[g]-d.dif[g]); int cur=0; int j;
  			for(j=0;j<n;j++)
  			{
  				node v=b[j];
  				if(v.dif[i]==0&&cur==0) break;
  				if(cur+v.dif[i]<=0) break;
  				else cur+=v.dif[i];
  			}
  			ans=Math.max(ans, j);
  		}
  		out.println(ans);
  	}
  	@Override
  	public void run() {
  		try {  init();  } 
  		catch (FileNotFoundException e) {  e.printStackTrace();   }
  
  		int t = in.ni();
  
  		for(int i=1;i<=t;i++)
  		{
  			solve(); out.flush();
  		}
  	}
  	private FastInput in;    private PrintWriter out;
  	public static void main(String[] args) throws Exception {	 new d3prac().run();	 }
  
  	private void init() throws FileNotFoundException {
  		InputStream inputStream = System.in; 	 OutputStream outputStream = System.out;
  		try {  if (!console && System.getProperty("user.name").equals("sachan")) {
  			outputStream = new FileOutputStream("/home/sachan/Desktop/output.txt");
  			inputStream = new FileInputStream("/home/sachan/Desktop/input.txt");   	}
  		}	catch (Exception ignored) {	}
  		out = new PrintWriter(outputStream); 	 in = new FastInput(inputStream);
  	}
  	static class FastInput { InputStream obj;
  	public FastInput(InputStream obj) {	this.obj = obj;	}
  	byte inbuffer[] = new byte[1024];  int lenbuffer = 0, ptrbuffer = 0;
  	int readByte() { if (lenbuffer == -1) throw new InputMismatchException();
  	if (ptrbuffer >= lenbuffer) { ptrbuffer = 0;
  	try { lenbuffer = obj.read(inbuffer);  }
  	catch (IOException e) { throw new InputMismatchException(); } }    
  	if (lenbuffer <= 0) return -1;return inbuffer[ptrbuffer++]; }
  
  	String ns() { int b = skip();StringBuilder sb = new StringBuilder();
  	while (!(isSpaceChar(b)))	  { sb.appendCodePoint(b);b = readByte(); }return sb.toString();}
  
  	int ni() { int num = 0, b;boolean minus = false;
  	while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
  	if (b == '-') { minus = true;b = readByte(); }
  	while (true) { if (b >= '0' && b <= '9') { num = num * 10 + (b - '0'); } else {
  		return minus ? -num : num; }b = readByte(); }}
  
  	long nl() { long num = 0;int b;boolean minus = false;
  	while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
  	if (b == '-') { minus = true;b = readByte(); }
  	while (true) { if (b >= '0' && b <= '9') { num = num * 10L + (b - '0'); } else {
  		return minus ? -num : num; }b = readByte(); } }
  
  	boolean isSpaceChar(int c) { return (!(c >= 33 && c <= 126)); }
  	int skip() { int b;while ((b = readByte()) != -1 && isSpaceChar(b)) ;return b; }
  	float nf() {return Float.parseFloat(ns());}
  	double nd() {return Double.parseDouble(ns());}
  	char nc() {return (char) skip();}
  	}
  }