CSES - Word Combinations
  • Time limit: 1.00 s
  • Memory limit: 512 MB

You are given a string of length nn and a dictionary containing kk words. In how many ways can you create the string using the words?

Input

The first input line has a string containing nn characters between a–z.

The second line has an integer kk: the number of words in the dictionary.

Finally there are kk lines describing the words. Each word is unique and consists of characters a–z.

Output

Print the number of ways modulo 109+710^9+7.

Constraints

  • 1n50001 \le n \le 5000
  • 1k1051 \le k \le 10^5
  • the total length of the words is at most 10610^6

Example

Input:

ababc
4
ab
abab
c
cb

Output:

2

Explanation: The possible ways are ab+ab+c and abab+c.