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.util.*;
  import java.io.*;
  import java.lang.*;
  
  public class Main {
      //input
      static out op = new out();
      static inp ip = new inp();
      static FastReader sc = new FastReader();
      static BufferedWriter output = new BufferedWriter( 
          new OutputStreamWriter(System.out));
      static long inf = (long)1e9+7;
     
     static long mod = (long)1e18+7;
     static long z = 0;
  
     static void sol() throws Exception{
        int n = ip.in();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        int[] d = new int[n];
        int[] e = new int[n];
        
        ArrayList<char[]> sa = new ArrayList<>();
        for(int i=0;i<n;i++){
           char[] s = ip.cain();
           sa.add(s);
        }
        
        for(int i=0;i<n;i++){
           for(char cc:sa.get(i)){
              if(cc == 'a')a[i]++;
              else if(cc == 'b')b[i]++;
              else if(cc == 'c')c[i]++;
              else if(cc == 'd')d[i]++;
              else e[i]++;
           }
           int l = sa.get(i).length;
           a[i] = a[i] - (l-a[i]);
           b[i] = b[i] - (l-b[i]);
           c[i] = c[i] - (l-c[i]);
           d[i] = d[i] - (l-d[i]);
           e[i] = e[i] - (l-e[i]);
        }
        
        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);
        Arrays.sort(d);
        Arrays.sort(e);
        
        int mx = 0;
        int sum = 0;
        int cnt = 0;
        for(int i=n-1;i>=0;i--){
           sum = sum + a[i];
           if(sum <= 0)break;
           cnt++;
        }
        //op.sbln("a "+cnt);
        mx = Math.max(mx,cnt);
        
        sum = 0;
        cnt = 0;
        for(int i=n-1;i>=0;i--){
           sum = sum + b[i];
           if(sum <= 0)break;
           cnt++;
        }
        mx = Math.max(mx,cnt);
        
        sum = 0;
        cnt = 0;
        for(int i=n-1;i>=0;i--){
           sum = sum + c[i];
           if(sum <= 0)break;
           cnt++;
        }
        mx = Math.max(mx,cnt);
        
        sum = 0;
        cnt = 0;
        for(int i=n-1;i>=0;i--){
           sum = sum + d[i];
           if(sum <= 0)break;
           cnt++;
        }
        mx = Math.max(mx,cnt);
        
        sum = 0;
        cnt = 0;
        for(int i=n-1;i>=0;i--){
           sum = sum + e[i];
           if(sum <= 0)break;
           cnt++;
        }
        mx = Math.max(mx,cnt);
        
        op.sbln(mx);
     }
     
     static long gcd(long a,long b){
       if(b==0)
       return a;
       return gcd(b,a%b);
     }
     
     public static void main(String[] args) throws Exception { 
         
        int t = ip.in();
        while(t-- > 0){
           sol();
        }
        op.output.flush();
      }
     //  static class Node implements Comparable<Node>{
     //     int data;
     //     int ind;
     //    //  Node left,right;
     //    //  Node(){
     //    //       left = null;
     //    //       right = null;
     //    //  }
     //     Node(int ind,int data){
     //          this.data = data;
     //          this.ind = ind;
     //     }
      
     //       @Override
     //       public int compareTo(Node o) {
     //           if(this.data == o.data)
     //           return this.ind - o.ind;
     //           // TODO Auto-generated method stub
     //           return this.data - o.data;
     //       }
     //  }
  }
  
  
  class FastReader 
  { 
      BufferedReader br; 
      StringTokenizer st; 
  
      public FastReader() 
      { 
          br = new BufferedReader(new
                   InputStreamReader(System.in)); 
      } 
  
      String next() 
      { 
          while (st == null || !st.hasMoreElements()) 
          { 
              try
              { 
                  st = new StringTokenizer(br.readLine()); 
              } 
              catch (IOException  e) 
              { 
                  e.printStackTrace(); 
              } 
          } 
          return st.nextToken(); 
      } 
  
      int nextInt() 
      { 
          return Integer.parseInt(next()); 
      } 
  
      long nextLong() 
      { 
          return Long.parseLong(next()); 
      } 
  
      double nextDouble() 
      { 
          return Double.parseDouble(next()); 
      } 
  
      String nextLine() 
      { 
          String str = ""; 
          try
          { 
              str = br.readLine(); 
          } 
          catch (IOException e) 
          { 
              e.printStackTrace(); 
          } 
          return str; 
      }
  
  }
  class inp{
      FastReader sc = new FastReader();
      int in(){
          int a = sc.nextInt();
          return a;
      }
      long lin(){
          long a = sc.nextLong();
          return a;
      }
      char cin(){
          char c = sc.next().charAt(0);
          return c;
      }
      char[] cain(){
          char[] a = sc.nextLine().toCharArray();
          return a;
      }
      int[] arrin(int n){
          int [] arr = new int[n];
          for(int i=0;i<n;i++)
              arr[i] = in();
  
          return arr;
      }
      int[] mm_arr(int[] arr){
          int max = Integer.MIN_VALUE;
          int min = Integer.MAX_VALUE;
          for(int i=0;i<arr.length;i++){
              max = Math.max(max,arr[i]);
              min = Math.min(min,arr[i]);
          }
          int ans[] = {max,min};
          return ans;
      }
      int[] srt(int[] arr){
          Arrays.sort(arr);
          return arr;
      }
      long pow(long a,long b){
          if(b == 0)return 1;
          long res = pow(a,b/2);
          //System.out.println(res + " " + b + " " + (b&1));
          if((b&1) == 0)return res*res;
          return a*res*res; 
      }
  
     //  boolean[] prime(){
     //     boolean prime[] = new boolean[100000001];
     //     Arrays.fill(prime,true);
     //     for (int p = 2; p * p <= 10000000; p++)
     //     {
     //          // If prime[p] is not changed,
     //          // then it is a prime
     //          if (prime[p] == true)
     //          {
     //              // Update all multiples
     //              // of p greater than or
     //              // equal to the square of it
     //              // numbers which are multiple
     //              // of p and are less than p^2
     //              // are already been marked.
     //              for (int i = p * p; i <= 10000000; i += p)
     //                 prime[i] = false;
     //          }
     //     }
     //     return prime;
     //  }
  }
  class out{
      BufferedWriter output = new BufferedWriter( 
          new OutputStreamWriter(System.out)); 
  
      void sb(String s) throws IOException {
          output.write(s);
      }
      void sbln(Object s) throws IOException {
          output.write(s+"\n");
      }
      void yes() throws IOException{
          output.write("YES\n");
      }
      void no() throws IOException{
          output.write("NO\n");
      }
  }