CSES - E4590 2016 6 - Dictionary
  • Time limit: 1.00 s
  • Memory limit: 512 MB

Given a string ss with nn characters and a dictionary with kk words w1,w2,,wkw_1, w_2, \ldots, w_k, compute how many ways there is to produce the given string by concatenating words in the dictionary.

Input

The first line has the exactly nn characters, the string ss.

The next line contains a single integer, kk, the number of words in the dictionary.

The rest kk lines each contain one word in the dictionary.

Output

Output the number of ways modulo 109+710^9+7

Limits

  • 1n50001 \le n \le 5000
  • 1k1051 \le k \le 10^5
  • The combined length of all words in the dictionary is at most 10610^6.
  • Each word consists of only English lower case letters a-z.

Example

Input:

ababc
4
ab
abab
c
cb

Output:

2

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