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 Contest1551C
  {
  	static class InputReader {
  		BufferedReader reader;
  		StringTokenizer tokenizer;
  		public InputReader(InputStream stream) {
  			reader = new BufferedReader(new InputStreamReader(stream), 32768);
  			tokenizer = null;
  		}
  		String next() { // reads in the next string
  			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
  				try {
  					tokenizer = new StringTokenizer(reader.readLine());
  				} catch (IOException e) {
  					throw new RuntimeException(e);
  				}
  			}
  			return tokenizer.nextToken();
  		}
  		public int nextInt() { // reads in the next int
  			return Integer.parseInt(next());
  		}
  		public long nextLong() { // reads in the next long
  			return Long.parseLong(next());
  		}
  		public double nextDouble() { // reads in the next double
  			return Double.parseDouble(next());
  			}
  		}
  	static InputReader r = new InputReader(System.in);
  	static PrintWriter pw = new PrintWriter(System.out);
  	public static void main(String[] args)
  	{
  		//LOOK FOR INT OVERFLOW
  		int t = r.nextInt();
  		while (t > 0)
  		{
  			t--;
  			int n = r.nextInt();
  			ArrayList<hiA> a = new ArrayList<hiA>();
  			ArrayList<hiB> b = new ArrayList<hiB>();
  			ArrayList<hiC> c = new ArrayList<hiC>();
  			ArrayList<hiF> f = new ArrayList<hiF>();
  			ArrayList<hiE> e = new ArrayList<hiE>();
  			for (int i = 0; i < n; i  ++)
  			{
  				String s = r.next();
  				int count1 = 0;
  				int count2 = 0;
  				int count3 = 0;
  				int count4 = 0;
  				int count5 = 0;
  				for (int j = 0; j < s.length(); j ++)
  				{
  					if (s.charAt(j) == 'a')
  					{
  						count1 ++;
  					}
  					else if (s.charAt(j) == 'b')
  					{
  						count2 ++;
  					}
  					else if (s.charAt(j) == 'c')
  					{
  						count3 ++;
  					}
  					else if (s.charAt(j) == 'd')
  					{
  						count4 ++;
  					}
  					else
  					{
  						count5 ++;
  					}
  				}
  
  				a.add(new hiA(count1,count2,count3,count4,count5));
  				b.add(new hiB(count1,count2,count3,count4,count5));
  				c.add(new hiC(count1,count2,count3,count4,count5));
  				f.add(new hiF(count1,count2,count3,count4,count5));
  				e.add(new hiE(count1,count2,count3,count4,count5));
  				
  			}
  			
  			Collections.sort(a);
  			Collections.sort(b);
  			Collections.sort(c);
  			Collections.sort(f);
  			Collections.sort(e);
  			int ans1; int ans2; int ans3; int ans4; int ans5;
  			int i = n - 1;
  			int sum = 0;
  			while ((i < n - 1 && i >= 0 && sum > 0) || i == n - 1)
  			{
  				sum += (a.get(i).v-a.get(i).x-a.get(i).w-a.get(i).y-a.get(i).z);
  				i --;
  			}
  			
  			if (i == -1 && sum > 0)
  			{
  				ans1 = n-i-1;
  			}
  			else
  			{
  				ans1 = n - i - 2;
  			}
  			i = n - 1;
  			sum = 0;
  			while ((i < n - 1 && i >= 0 && sum > 0) || i == n - 1)
  			{
  				sum += (b.get(i).w-b.get(i).v-b.get(i).x-b.get(i).y-b.get(i).z);
  				i --;
  			}
  			
  			if (i == -1 && sum > 0)
  			{
  				ans2 = n-i-1;
  			}
  			else
  			{
  				ans2 = n - i - 2;
  			}
  			i = n - 1;
  			sum = 0;
  			while ((i < n - 1 && i >= 0 && sum > 0) || i == n - 1)
  			{
  				sum += (c.get(i).x-c.get(i).v-c.get(i).w-c.get(i).y-c.get(i).z);
  				i --;
  			}
  			
  			if (i == -1 && sum > 0)
  			{
  				ans3 = n-i-1;
  			}
  			else
  			{
  				ans3 = n - i - 2;
  			}
  			i = n - 1;
  			sum = 0;
  			while ((i < n - 1 && i >= 0 && sum > 0) || i == n - 1)
  			{
  				sum += (f.get(i).y-f.get(i).v-f.get(i).w-f.get(i).x-f.get(i).z);
  				i --;
  			}
  			
  			if (i == -1 && sum > 0)
  			{
  				ans4 = n-i-1;
  			}
  			else
  			{
  				ans4 = n - i - 2;
  			}
  			i = n - 1;
  			sum = 0;
  			while ((i < n - 1 && i >= 0 && sum > 0) || i == n - 1)
  			{
  				sum += (e.get(i).z-e.get(i).v-e.get(i).w-e.get(i).y-e.get(i).x);
  				i --;
  			}
  			
  			if (i == -1 && sum > 0)
  			{
  				ans5 = n-i-1;
  			}
  			else
  			{
  				ans5 = n - i - 2;
  			}
  			pw.println(Math.max(Math.max(Math.max(ans5,ans4),Math.max(ans3, ans2)),ans1));
  		}
  		
  		pw.close();
  	}
  	
      static class hiA implements Comparable<hiA>
      {
      	int v,w,x,y,z;
      	public hiA(int _v, int _w,int _x, int _y, int _z)
      	{
      		v = _v;
      		w = _w;
      		x = _x;
      		y = _y;
      		z = _z;
      	}
      	public int compareTo(hiA p)
      	{
      		return Integer.compare(v-w-x-y-z, p.v-p.w-p.x-p.y-p.z);
      	}
  }
      static class hiB implements Comparable<hiB>
      {
      	int v,w,x,y,z;
      	public hiB(int _v, int _w,int _x, int _y, int _z)
      	{
      		v = _v;
      		w = _w;
      		x = _x;
      		y = _y;
      		z = _z;
      	}
      	public int compareTo(hiB p)
      	{
      		return Integer.compare(w-v-x-y-z, p.w-p.v-p.x-p.y-p.z);
      	}
      }
      static class hiC implements Comparable<hiC>
      {
      	int v,w,x,y,z;
      	public hiC(int _v, int _w,int _x, int _y, int _z)
      	{
      		v = _v;
      		w = _w;
      		x = _x;
      		y = _y;
      		z = _z;
      	}
      	public int compareTo(hiC p)
      	{
      		return Integer.compare(x-v-w-y-z, p.x-p.w-p.v-p.y-p.z);
      	}
      }
      static class hiF implements Comparable<hiF>
      {
      	int v,w,x,y,z;
      	public hiF(int _v, int _w,int _x, int _y, int _z)
      	{
      		v = _v;
      		w = _w;
      		x = _x;
      		y = _y;
      		z = _z;
      	}
      	public int compareTo(hiF p)
      	{
      		return Integer.compare(y-v-w-x-z, p.y-p.w-p.v-p.x-p.z);
      	}
      }
      static class hiE implements Comparable<hiE>
      {
      	int v,w,x,y,z;
      	public hiE(int _v, int _w,int _x, int _y, int _z)
      	{
      		v = _v;
      		w = _w;
      		x = _x;
      		y = _y;
      		z = _z;
      	}
      	public int compareTo(hiE p)
      	{
      		return Integer.compare(z-v-w-x-y, p.z-p.w-p.v-p.x-p.y);
      	}
      }
  }