In the Lazy Spelling Bee, a contestant is given a target word W to spell. An answer word A is acceptable when both of these hold.
- A has the same length as W.
- For every i, the i-th letter of A equals the (i−1)-th, i-th, or (i+1)-th letter of W.
W has no 0-th letter, so the first letter of A must equal the first or the second letter of W. In the same way, the last letter of A must equal the last or the next to last letter of W. 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+7.