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: /*
   * To change this license header, choose License Headers in Project Properties.
   * To change this template file, choose Tools | Templates
   * and open the template in the editor.
   */
   
  /**
   *
   * @author wilso
   */
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.PrintWriter;
  import java.util.*;
  public class codeforces {
      static final long MOD2 = 998_244_353;
      static final long X = 10000000000L;
      public static void main(String[] args) {
          FastScanner sc = new FastScanner();
          PrintWriter pw = new PrintWriter(System.out);
  //        Scanner sc = new Scanner(System.in);
          int tc = sc.ni();
  //        int tc = 1;
          for (int rep = 0; rep < tc; rep++) {
              int N = sc.ni();
              String[] arr = new String[N];
              for (int i = 0; i < arr.length; i++) arr[i] = sc.next();
              pw.println(solve(arr));
              
          }
          
          pw.close();
      }
      static int solve(String[] arr) {
          int ret = 0;
         for (char c : "abcde".toCharArray()) {
             List<Integer> diffs = new ArrayList();
             for (String s : arr) {
                 int want = 0;
                 int others = 0;
                 for (char x : s.toCharArray()) {
                     if (x == c) {
                         want++;
                     }
                     else {
                         others++;
                     }
                 }
                 diffs.add(want - others);
             }
             Collections.sort(diffs);
             int allow = 0;
             int count = 0;
             for (int i = diffs.size() - 1; i >= 0; i--) {
                 if (allow + diffs.get(i) > 0) {
                     allow += diffs.get(i);
                     count += 1;
                 }
                 else {
                     break;
                 }
             }
             ret = Math.max(ret, count);
         }      
         return ret;
      }
  
   
   
      static int greaterThan(long[] arr, long target) {
  	int lo = 0, hi = arr.length- 1;
  	while(lo < hi) { // observe this time it is "<" operator, not "<="
  		int mid = lo + (hi-lo)/2;
  		if(arr[mid] <= target) lo = mid+1;
  		else hi = mid;
  	}
  	return arr[lo] > target ? lo : -1;
  }
      static int smallerThan(long[] arr, long target) {
  	int lo = 0, hi = arr.length- 1;
  	while(lo < hi) {
  		int mid = lo + (hi-lo+1)/2; // Note that I used ceil here otherwise it could go in infinite loop
  		if(arr[mid] < target) lo = mid;
  		else hi = mid-1;
  	}
  	return arr[lo] < target ? lo : -1;
  }
    
      static int[] reduce(int[] temp) {
          int[] frac = new int[] {temp[0], temp[1]};
          int curr = gcd(frac[0], frac[1]);
          while (curr != 1) {
              frac[0] /= curr;
              frac[1] /= curr;
              curr = gcd(frac[0], frac[1]);
          }
          return frac;
      }
      static int summation(int x) {
          return x * (x+1) / 2;
      }  
      static long summation(long x) {
          return x*(x+1) / 2;
      }
      static long pow(long num, long exp, long mod){
          long ans=1;
          for(int i=1;i<=exp;i++){
              ans=(ans*num)%mod;
          }
          return ans;
      }
      static boolean isPrime(int n)
      {
   
          if (n <= 1)
              return false;
          else if (n == 2)
              return true;
          else if (n % 2 == 0)
              return false;
          for (int i = 3; i <= Math.sqrt(n); i += 2) {
              if (n % i == 0)
                  return false;
          }
          return true;
      }
      static int gcd(int a, int b)
      {
          if (a == 0)
              return b; 
          return gcd(b % a, a); 
      }
      static long gcd(long a, long b) {
          if (a == 0) return b;
          return gcd(b % a, a);
      }
      static int lcm(int a, int b)
      {
          return (a / gcd(a, b)) * b;
      }
      public static void sort(int[] arr) {
          Random rgen = new Random();
          for (int i = 0; i < arr.length; i++) {
              int r = rgen.nextInt(arr.length);
              int temp = arr[i];
              arr[i] = arr[r];
              arr[r] = temp;
          }
          Arrays.sort(arr);
      }
      public static void sort(long[] arr) {
          Random rgen = new Random();
          for (int i = 0; i < arr.length; i++) {
              int r = rgen.nextInt(arr.length);
              long temp = arr[i];
              arr[i] = arr[r];
              arr[r] = temp;
          }
          Arrays.sort(arr);
      }
      static int charint(char c) {
          return Integer.parseInt(String.valueOf(c));
      }
      
      /* */
      //printing methods
      /* */
      //WOW!
      /* */
      public static void printArr(PrintWriter pw, int[] arr) {
          StringBuilder sb = new StringBuilder();
          for (int x : arr) {
              sb.append(x + "");
          }
          sb.setLength(sb.length() - 1);
          pw.println(sb.toString());
      }
      public static void printArr2d(PrintWriter pw, int[][] arr) {
          StringBuilder sb = new StringBuilder();
          for (int[] row : arr) {
              for (int x : row) {
                  sb.append(x + " ");
              }
              sb.setLength(sb.length() - 1);
              sb.append("\n");
          }
          pw.println(sb.toString());
      }
  }
   
  class FastScanner {
      BufferedReader br;
      StringTokenizer st;
   
      public FastScanner() {
          br = new BufferedReader(new InputStreamReader(System.in), 32768);
          st = null;
      }
   
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
                  
              }
          }
          return st.nextToken();
      }
   
      int ni() {
          return Integer.parseInt(next());
      }
   
      int[] intArray(int N) {
          int[] ret = new int[N];
          for (int i = 0; i < N; i++)
              ret[i] = ni();
          return ret;
      }
   
      long nl() {
          return Long.parseLong(next());
      }
   
      long[] longArray(int N) {
          long[] ret = new long[N];
          for (int i = 0; i < N; i++)
              ret[i] = nl();
          return ret;
      }
   
      double nd() {
          return Double.parseDouble(next());
      }
   
      String nextLine() {
          String str = "";
          try {
              str = br.readLine();
          } catch (IOException e) {
              e.printStackTrace();
          }
          return str;
      }
  }
   
  class MultiSet {
      TreeMap<Long, Integer> map = new TreeMap<>();
      private int size = 0;
      public MultiSet() {
      }
      public void add(Long val) {
          map.put(val, map.getOrDefault(val, 0) + 1);
          size++;
      }
      public void remove(Long val) {
          map.put(val, map.get(val) - 1);
          if (map.get(val) == 0) {
              map.remove(val);
          }
          size--;
      }
      public int size() {
          return size;
      }
      public Long higher(Long val) {
          return map.higherKey(val);
      }
      public Long lower(Long val) {
          return map.lowerKey(val);
      }
      public Long ceiling(Long val) {
          return map.ceilingKey(val);
      }
      public Long floor(Long val) {
          return map.floorKey(val);
      }
      public Long first() {
          return map.firstKey();
      }
      public Long last() {
          return map.lastKey();
      }
      public boolean isEmpty() {
          return map.isEmpty();
      }
  }