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.OutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  import java.io.PrintWriter;
  import java.util.Arrays;
  import java.io.BufferedWriter;
  import java.util.InputMismatchException;
  import java.io.IOException;
  import java.io.Writer;
  import java.io.OutputStreamWriter;
  import java.util.Comparator;
  import java.io.InputStream;
  
  /**
   * Built using CHelper plug-in
   * Actual solution is at the top
   *
   * @author Akshay Mishra
   */
  public class Main {
      public static void main(String[] args) {
          InputStream inputStream = System.in;
          OutputStream outputStream = System.out;
          InputReader in = new InputReader(inputStream);
          OutputWriter out = new OutputWriter(outputStream);
          CInterestingStory solver = new CInterestingStory();
          solver.solve(1, in, out);
          out.close();
      }
  
      static class CInterestingStory {
          public void solve(int testNumber, InputReader in, OutputWriter out) {
              int test = in.nextInt();
              for (int tt = 0; tt < test; tt++) {
                  int n = in.nextInt();
                  CInterestingStory.Pair a[] = new CInterestingStory.Pair[n];
                  CInterestingStory.Pair b[] = new CInterestingStory.Pair[n];
                  CInterestingStory.Pair c[] = new CInterestingStory.Pair[n];
                  CInterestingStory.Pair d[] = new CInterestingStory.Pair[n];
                  CInterestingStory.Pair e[] = new CInterestingStory.Pair[n];
                  for (int i = 0; i < n; i++) {
                      String str = in.next();
                      char arr[] = str.toCharArray();
                      int size = arr.length;
                      int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0, cnt5 = 0;
                      for (int j = 0; j < size; j++) {
                          if (arr[j] == 'a') {
                              cnt1++;
                          } else if (arr[j] == 'b') {
                              cnt2++;
                          } else if (arr[j] == 'c') {
                              cnt3++;
                          } else if (arr[j] == 'd') {
                              cnt4++;
                          } else {
                              cnt5++;
                          }
                      }
                      a[i] = new CInterestingStory.Pair(cnt1, size - cnt1, 2 * cnt1 - size);
                      b[i] = new CInterestingStory.Pair(cnt2, size - cnt2, 2 * cnt2 - size);
                      c[i] = new CInterestingStory.Pair(cnt3, size - cnt3, 2 * cnt3 - size);
                      d[i] = new CInterestingStory.Pair(cnt4, size - cnt4, 2 * cnt4 - size);
                      e[i] = new CInterestingStory.Pair(cnt5, size - cnt5, 2 * cnt5 - size);
                  }
                  Arrays.sort(a, new CInterestingStory.SortByDiff());
                  Arrays.sort(b, new CInterestingStory.SortByDiff());
                  Arrays.sort(c, new CInterestingStory.SortByDiff());
                  Arrays.sort(d, new CInterestingStory.SortByDiff());
                  Arrays.sort(e, new CInterestingStory.SortByDiff());
                  int res = 0, temp = 0;
                  int actuallettercnt = 0, otherlettercnt = 0;
                  for (int i = 0; i < n; i++) {
                      if (actuallettercnt + a[i].letter > otherlettercnt + a[i].others) {
                          temp++;
                          actuallettercnt += a[i].letter;
                          otherlettercnt += a[i].others;
                      }
                  }
                  res = Math.max(res, temp);
                  temp = 0;
                  actuallettercnt = 0;
                  otherlettercnt = 0;
                  for (int i = 0; i < n; i++) {
                      if (actuallettercnt + b[i].letter > otherlettercnt + b[i].others) {
                          temp++;
                          actuallettercnt += b[i].letter;
                          otherlettercnt += b[i].others;
                      }
                  }
                  res = Math.max(res, temp);
                  temp = 0;
                  actuallettercnt = 0;
                  otherlettercnt = 0;
                  for (int i = 0; i < n; i++) {
                      if (actuallettercnt + c[i].letter > otherlettercnt + c[i].others) {
                          temp++;
                          actuallettercnt += c[i].letter;
                          otherlettercnt += c[i].others;
                      }
                  }
                  res = Math.max(res, temp);
                  temp = 0;
                  actuallettercnt = 0;
                  otherlettercnt = 0;
                  for (int i = 0; i < n; i++) {
                      if (actuallettercnt + d[i].letter > otherlettercnt + d[i].others) {
                          temp++;
                          actuallettercnt += d[i].letter;
                          otherlettercnt += d[i].others;
                      }
                  }
                  res = Math.max(res, temp);
                  temp = 0;
                  actuallettercnt = 0;
                  otherlettercnt = 0;
                  for (int i = 0; i < n; i++) {
                      if (actuallettercnt + e[i].letter > otherlettercnt + e[i].others) {
                          temp++;
                          actuallettercnt += e[i].letter;
                          otherlettercnt += e[i].others;
                      }
                  }
                  res = Math.max(res, temp);
                  out.println(res);
              }
          }
  
          static class Pair {
              int letter;
              int others;
              int diff;
  
              public Pair(int letter, int others, int diff) {
                  this.letter = letter;
                  this.others = others;
                  this.diff = diff;
              }
  
          }
  
          static class SortByDiff implements Comparator<CInterestingStory.Pair> {
              public int compare(CInterestingStory.Pair p1, CInterestingStory.Pair p2) {
                  return p2.diff - p1.diff;
              }
  
          }
  
      }
  
      static class InputReader {
          private InputStream stream;
          private byte[] buf = new byte[1024];
          private int curChar;
          private int numChars;
          private InputReader.SpaceCharFilter filter;
  
          public InputReader(InputStream stream) {
              this.stream = stream;
          }
  
          public int read() {
              if (numChars == -1) {
                  throw new InputMismatchException();
              }
              if (curChar >= numChars) {
                  curChar = 0;
                  try {
                      numChars = stream.read(buf);
                  } catch (IOException e) {
                      throw new InputMismatchException();
                  }
                  if (numChars <= 0) {
                      return -1;
                  }
              }
              return buf[curChar++];
          }
  
          public int nextInt() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              int res = 0;
              do {
                  if (c < '0' || c > '9') {
                      throw new InputMismatchException();
                  }
                  res *= 10;
                  res += c - '0';
                  c = read();
              } while (!isSpaceChar(c));
              return res * sgn;
          }
  
          public String nextString() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              StringBuilder res = new StringBuilder();
              do {
                  if (Character.isValidCodePoint(c)) {
                      res.appendCodePoint(c);
                  }
                  c = read();
              } while (!isSpaceChar(c));
              return res.toString();
          }
  
          public boolean isSpaceChar(int c) {
              if (filter != null) {
                  return filter.isSpaceChar(c);
              }
              return isWhitespace(c);
          }
  
          public static boolean isWhitespace(int c) {
              return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
          }
  
          public String next() {
              return nextString();
          }
  
          public interface SpaceCharFilter {
              public boolean isSpaceChar(int ch);
  
          }
  
      }
  
      static class OutputWriter {
          private final PrintWriter writer;
  
          public OutputWriter(OutputStream outputStream) {
              writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
          }
  
          public OutputWriter(Writer writer) {
              this.writer = new PrintWriter(writer);
          }
  
          public void close() {
              writer.close();
          }
  
          public void println(int i) {
              writer.println(i);
          }
  
      }
  }
  
  