Problem I
Word Puzzle

Young Anna recently indulges in a word puzzle app on her phone. A word puzzle is a single English word with several blanks. Each blank represents a letter to be filled. For example, the word “programming” may appear as a puzzle p_o_rammin_. When solving a puzzle, Anna first clicks on a blank and then begins typing letters. The app automatically advances to the next blank once Anna types a letter. When there are no more blanks to the right of the filled letter, the app jumps back to the beginning of the word and advances from there. Anna keeps typing until all blanks are filled. To solve the puzzle p_o_rammin_, Anna may click on the first blank and type rgg. Alternatively, she may click on the second blank and then type ggr.
One day Anna shows you a puzzle that she solved along with
the sequence of letters she typed. Could you tell how many
different puzzles can be the one that Anna solved? Two puzzles
are different if they have blanks at different positions, e.g.
if the puzzle word is programming and Anna
typed rgg, there can be two possible
puzzles: p_o_rammin_ and pro__ammin_. As the answer can be large, output the
answer modulo
Input
The first line of input has a single string
Output
Output the number of different puzzles that can be the one
solved by Anna, modulo
Sample Input 1 | Sample Output 1 |
---|---|
programming rgg |
2 |
Sample Input 2 | Sample Output 2 |
---|---|
aabbaa aba |
12 |
Sample Input 3 | Sample Output 3 |
---|---|
acca acac |
0 |