Tommy has just invented an interesting string encoding algorithm, which is described below.
- For every string
, we may define a character-mapping function
, which maps every character occurring in
to a lowercase letter, as below
%20%3D%20%5Coperatorname%7Bchr%7D(G(c%2C%20S)))
where
)
is the
)
-th lowercase Latin letter, and
)
is the number of different characters after the last occurrence of

in

.
- To encode a string
by Tommy's algorithm, replace every character
in
by
simultaneously.
For example, the encoded string of "abc" is "cba", and the encoded string of "cac" is "aba".
You are given a string of length

and then encode all the
nonempty prefixes. Your task is to find the encoded string that has the greatest lexicographical order among all the encoded strings.