cho.sh
Notes
Loading...

Unicorn

Time limit

2s

Memory limit

128 MB

Problem

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.

  1. Pick up the unicorn.
  2. Move it at least 333 squares in one of the four cardinal directions.
  3. Move it at least 222 squares in one of the two directions perpendicular to the direction just used.
  4. Put the unicorn down.

The chessboard has size N×MN \times MN×M. Each square contains one of the first LLL uppercase English letters.

Given NNN, MMM, LLL, 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,0071{,}000{,}000{,}0071,000,000,007.

Input

The first line contains NNN, MMM, and LLL. Both NNN and MMM are positive integers no greater than 300300300, and LLL is a positive integer no greater than 262626.

The second line contains the word. Its length is at most 505050, and it consists only of uppercase English letters.

From the third line, NNN lines follow. Each of these lines is a string of length MMM describing the letters written on the chessboard.

Output

Print the number of paths modulo 1,000,000,0071{,}000{,}000{,}0071,000,000,007 on the first line.