Given the periodic table and a series of words, determine whether the word can be formed using the elements in the periodic table. If there are multiple ways of doing so, select the one with the fewest number of required elements. If multiple options use the same minimal number of elements, sum the atomic numbers (atomic numbers are implied by the order in which the elements are read in) used for each option, and select the one with the smallest value. If there are still multiple, then there's probably no point, as it is most likely too obvious, so in these cases, simply print “Too Obvious” for the given word.
An 'element' always starts with a capital letter followed by zero or more lower case letters.
<Number of cases> <number of elements> <elements...> <number of words> <words...>
If a given word has a deterministic answer based on the periodic table provided and the above stated rules, print the case number and the series of elements used, forming the word, but with square brackets around them to indicate the elements. One example output line might be: “[Ba][Na][Na]”
Sample Input | Sample Output |
---|---|
1 4 Ba Na N A 2 banana nan |
[Ba][Na][Na] [Na][N] |