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.*;
  
  public class Solution
  {
      static class Reader {
          final private int BUFFER_SIZE = 1 << 16;
          private DataInputStream din;
          private byte[] buffer;
          private int bufferPointer, bytesRead;
   
          public Reader()
          {
              din = new DataInputStream(System.in);
              buffer = new byte[BUFFER_SIZE];
              bufferPointer = bytesRead = 0;
          }
   
          public Reader(String file_name) throws IOException
          {
              din = new DataInputStream(
                  new FileInputStream(file_name));
              buffer = new byte[BUFFER_SIZE];
              bufferPointer = bytesRead = 0;
          }
   
          public String readLine() throws IOException
          {
              byte[] buf = new byte[64]; // line length
              int cnt = 0, c;
              while ((c = read()) != -1) {
                  if (c == '\n') {
                      if (cnt != 0) {
                          break;
                      }
                      else {
                          continue;
                      }
                  }
                  buf[cnt++] = (byte)c;
              }
              return new String(buf, 0, cnt);
          }
   
          public int nextInt() throws IOException
          {
              int ret = 0;
              byte c = read();
              while (c <= ' ') {
                  c = read();
              }
              boolean neg = (c == '-');
              if (neg)
                  c = read();
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
   
              if (neg)
                  return -ret;
              return ret;
          }
   
          public long nextLong() throws IOException
          {
              long ret = 0;
              byte c = read();
              while (c <= ' ')
                  c = read();
              boolean neg = (c == '-');
              if (neg)
                  c = read();
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
              if (neg)
                  return -ret;
              return ret;
          }
   
          public double nextDouble() throws IOException
          {
              double ret = 0, div = 1;
              byte c = read();
              while (c <= ' ')
                  c = read();
              boolean neg = (c == '-');
              if (neg)
                  c = read();
   
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
   
              if (c == '.') {
                  while ((c = read()) >= '0' && c <= '9') {
                      ret += (c - '0') / (div *= 10);
                  }
              }
   
              if (neg)
                  return -ret;
              return ret;
          }
   
          private void fillBuffer() throws IOException
          {
              bytesRead = din.read(buffer, bufferPointer = 0,
                                   BUFFER_SIZE);
              if (bytesRead == -1)
                  buffer[0] = -1;
          }
   
          private byte read() throws IOException
          {
              if (bufferPointer == bytesRead)
                  fillBuffer();
              return buffer[bufferPointer++];
          }
   
          public void close() throws IOException
          {
              if (din == null)
                  return;
              din.close();
          }
      }
      
     
    static int parent(int a , int p[])
    {
        if(a == p[a])
        return a;
        
        return p[a] = parent(p[a],p);
    }
    
    static void union(int a , int b , int p[] , int size[])
    {
        a = parent(a,p);
        b = parent(b,p);
        
        if(a == b)
        return;
        
        if(size[a] < size[b])
        {
            int temp = a;
            a = b;
            b = temp;
        }
        
        p[b] = a;
        size[a] += size[b];
    }
    
    
    static long dp[][];
    static long f(int n , int m)
    {
        if(m == 0)
        return 1;
        
        if(dp[n][m] != -1)
        return dp[n][m];
        
        if(n < 9)
        dp[n][m] = f(n+1,m-1);
        
        else
        dp[n][m] = f(0,m-1)+f(1,m-1);
        
        dp[n][m] %= 1000000007;
        
        return dp[n][m];
    }
    
   static long getSum(int index , long BITree[])
      {
          long sum = 0; // Iniialize result
        
          // index in BITree[] is 1 more than
          // the index in arr[]
         // index = index + 1;
        
          // Traverse ancestors of BITree[index]
          while(index>0)
          {
              // Add current element of BITree 
              // to sum
              sum += BITree[index];
        
              // Move index to parent node in 
              // getSum View
              index -= index & (-index);
          }
          return sum;
      }
    
      // Updates a node in Binary Index Tree (BITree)
      // at given index in BITree. The given value 
      // 'val' is added to BITree[i] and all of 
      // its ancestors in tree.
      public static void updateBIT(int n, int index, 
                                          long val , long BITree[])
      {
          // index in BITree[] is 1 more than 
          // the index in arr[]
        //  index = index + 1;
        
          // Traverse all ancestors and add 'val'
          while(index <= n)
          {
          // Add 'val' to current node of BIT Tree
          BITree[index] += val;
        
          // Update index to that of parent 
          // in update View
          index += index & (-index);
          }
      }
      
      
     static int gcd(int a, int b)
  {
      if (a == 0)
          return b;
      return gcd(b % a, a);
  }
      public static void main(String []args) throws IOException
      {
          Scanner sc = new Scanner(System.in);
          int t = sc.nextInt();
         // sc.nextLine();
          while(t-- > 0)
          {
              int n = sc.nextInt();
              sc.nextLine();
              //String s = sc.nextLine();
              int arr[][] = new int[26][n];
              for(int i = 0 ; i < n ; i++)
              {
                  String s = sc.nextLine();
                  
                  for(int j = 0 ; j < 26 ; j++)
                  {
                      int cnt = 0;
                      for(int k = 0 ; k < s.length() ; k++)
                      {
                          if(s.charAt(k)-'a' == j)
                          cnt++;
                      }
                      arr[j][i] = 2*cnt-s.length();
                  }
              }
              
              int ans = 0;
              for(int i = 0 ; i < 26 ; i++)
              {
               Arrays.sort(arr[i]);   
               int tot = 0;
               for(int j = n-1 ; j >= 0 ;j--)
               {
                   tot += arr[i][j];
                   if(tot <= 0)
                   break;
                   
                   ans = Math.max(ans,n-j);
               }
              }
              System.out.println(ans);
          }
      }
  }