Lazy Spelling Bee (Small)

Count distinct words formed by replacing each letter with itself or an adjacent letter of the target word.

Easy3CombinatoricsStringInterviewNo attempts yetTime limit5sMemory limit512 MB

Problem

In the Lazy Spelling Bee, a contestant is given a target word WW to spell. An answer word AA is acceptable when both of these hold.

  • AA has the same length as WW.
  • For every ii, the ii-th letter of AA equals the (i1)(i-1)-th, ii-th, or (i+1)(i+1)-th letter of WW.

WW has no 00-th letter, so the first letter of AA must equal the first or the second letter of WW. In the same way, the last letter of AA must equal the last or the next to last letter of WW. The target word itself is always an acceptable answer.

For each target word, count the distinct acceptable answer words. The count can be very large, so print it modulo 109+710^9 + 7.

Input

The first line contains the number of test cases TT. Each of the following TT lines contains one string made only of lowercase English letters (a through z).

Limits

  • 1T1001 \le T \le 100
  • The length of each string is between 11 and 55.

Output

For each test case, print one line in the form Case #x: y, where xx is the test case number starting from 11 and yy is the number of distinct acceptable answer words modulo 109+710^9 + 7.

Hint

For the target word ag, the acceptable answers are aa, ag, ga, and gg, so there are four. For the target word aa, the only acceptable answer is aa.