This problem is based upon a true story. One day, Professor Oak realized that his flat had no insurance for several years, so his plan was to find a good deal and sign an insurance in a week. Only two days later (still with no insurance) he received a phone call alerting him that a huge water leak from his flat had seriously affected five other flats. The thoughts that crossed Prof. Oak’s mind were so outrageous that, later, he tried to excuse himself through combinatorial arguments. He pretended that he had just thought a random string. Because, there are so many strings that contain a given curse word, right?
Input consists of several cases, each with a curse word and two natural numbers and . Assume , , , and that has only lowercase letters chosen among the first of the alphabet.
For every case, print the number of words made up of exactly lowercase letters chosen among the first of the alphabet that contain the substring one or more times. Since this number can be very large, compute it modulo .
Input
casumdena 9 26 caca 5 3 caca 6 26 caca 1000000000 26
Output
1 6 2027 732270910