As you know, some molecules include digits as part of their chemical formula, like H2O, whereas others don’t, like NaCl.
Your program must process a sequence of molecules; it should ignore all molecules without numbers inside the chemical formula and, of the rest, it must report the most frequent formula(s) among those coming in the sequence before the first occurrence of NaCl (which is ignored from the counting as it does not have digits but, of course, is not ignored as an endmark).
Input
Input is a sequence of molecules. There is no information about whether they are organized in lines nor, if so, how. It is guaranteed that there is at least one occurrence of the molecule NaCl and that, before it, there is at least one occurrence of molecules with digits in their formula.
Output
Your program must print the most frequent molecule found in the sequence before the first occurrence of NaCl, under the condition that only molecules with numbers in their formula are to be considered. Molecules whose formulas contain just letters are to be ignored, except for the endmarker NaCl. In case of a tie, your program must output all the tied molecules, ordered from smaller ones to larger ones according to Python3’s str ordering. All molecules printed out must be each on a line with no extra spaces or lines.
Input
C8H12N4O3 C2H4O2 CaO CaS CO2 H2CO3 H2O C2H6O CaOH C6H8O6 CaH C9H8O4 C8H12N4O3 C2H6O CaOH C6H6 C8H12N4O3 CaH C2H6O CaOH H2O NaCl FeO SiO BaSO4 CaOH H2O FeS CaH C9H8O4 C8H12N4O3 AsH3 O3 KCN
Output
C2H6O C8H12N4O3
Input
H2O BaSO4 C6H6 BaSO4 H2O C6H6 BaSO4 O3 O3 O3 C8H11N H2O NaCl
Output
BaSO4 H2O O3