Let
be a string and
be a natural number. We define
as the result of concatening
exactly
times.
For instance, the third power of “abbc” is
“abbcabbcabbc”.
Given a string , rearrange its letters so that the result is the -th power of some string , where .
Input consists of several strings, each with between 2 and lowercase letters.
For each given string, print a way to rearrange its letters so that
the result is
,
for some string
and some
.
If there is more than one solution, choose the alphabetically largest.
If there is no solution, print “NO”.
Input
abba xyz ww oppoop aaaaaaaaiiii
Output
baba NO ww popopo iiaaaaiiaaaa