Some really mysterious organic material of Martian origin was found inside a micro-meteor that hit Antarctica last week. Now, the biologists want to find the most common DNA sequence on the organic patch (yes, the patch contains DNA; a quite exciting discovery).
As the programming expert of the team, your job is to write a program to process all the DNA sequences found, and spot the dominant gene (the most frequent DNA sequence).
Recall from high school bio class that DNA fragments can be described by sequences of four basic nucleotides: adenine (A), thymine (T), guanine (G) and cytosine (C), and a gene is nothing but a particular sequence of nucleotides. For example, a possible gene could be represented by the string ATGCAT.
Problem
Write a program that,
given a very long listing of gene descriptions,
finds the gene that occurs most frequently in the listing.
Input
The first line contains a positive integer C (1 <= C <= 70000) indicating the number of lines with DNA sequences. Each line has at most 2000 characters on it.
Each of the following C lines contains
a non-empty list of gene descriptions,
separated by a single space.
The length of each gene
description is known not to exceed 8.
Output
The output contains the most frequent gene found in the DNA sequences.
If there is a tie,
you should list all most frequent genes in alphabetic order and
in separate lines.
Sample Input
4 ATTT AGAGG ATGGGGGC AGAGG ACAT CAGG CATA AGAGG ATAAAA AGAGG TTTT
AGAGG