Enchanted Fortress

Elisabeth the Efficient, a famous magician, was called by Emmanuel the Empowered,
the mighty lord of the East Embarkmentlands, to enhance the magical protection of his enchanted fortress.

After arriving at the site and studying the structure of the fortress and the existing spells that
protect its integrity, Elisabeth found out the following properties of the spell to design:
itemize
    it should consist of symbols taken from the string ;
    all symbols should be unique;
    the strength of the spell depends only on which symbols are chosen, but not on their order;
    if symbols  and , , both exist in the spell,
          then its strength increases by .
itemize

For instance, if  and
equation*
    d = (arrayccc 1 & -1 & 2 
 - & 2 & -3 
 - & - & 1 array)
equation*
then a spell A has strength 1, ABC has strength 2,
and AC has strength 4.

However, the problem appeared to be too difficult to Elisabeth, because she has only little experience
of working with computers. Can you help her to find the strongest spell?

Input

The first line of the input file contains the string , that will not be empty and
may contain only big Latin letters or symbols !, ?, @, *.
All symbols will be pairwise different. Its length  will thus not exceed 30.

The following  lines contain the description of the matrix . The -th of these lines
() contains  integer numbers , , , ,
separated by single whitespace symbols. These numbers do not exceed  by the absolute values.

Output

Output the length of the strongest spell in the first line.
In the second line, output the spell itself. If there are multiple equally strongest spells,
output any of them.
