Unicorn

Count the number of paths on an N by M letter grid where a chess unicorn piece spells out a given word, modulo 1e9+7.

Hard8Dynamic programmingPrefix sumMatrixCombinatoricsNo attempts yetTime limit2sMemory limit128 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 33 squares in one of the four cardinal directions.
  3. Move it at least 22 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 M. Each square contains one of the first LL uppercase English letters.

Given NN, MM, LL, 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{,}007.

Input

The first line contains NN, MM, and LL. Both NN and MM are positive integers no greater than 300300, and LL is a positive integer no greater than 2626.

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

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

Output

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