A unicorn is a chess piece similar to a knight. A knight moves two squares in one direction and one square in a perpendicular direction. A unicorn instead moves more than two squares in one of the four cardinal directions, then more than one square in one of the two perpendicular directions.
More precisely, one move is performed as follows.
- Pick up the unicorn.
- Move it at least 3 squares in one of the four cardinal directions.
- Move it at least 2 squares in one of the two directions perpendicular to the direction just used.
- Put the unicorn down.
The chessboard has size N×M. Each square contains one of the first L uppercase English letters.
Given N, M, L, and a word, count the number of unicorn paths whose occupied squares spell the given word in order. Print the count modulo 1,000,000,007.