#jag2017autumnh. [jag2017autumn_h]Separate String

[jag2017autumn_h]Separate String

MathJax.Hub.Config({ tex2jax: { inlineMath: [["","",""], ["\\(","\\)"]], processEscapes: true }}); blockquote { font-family: Menlo, Monaco, "Courier New", monospace; color: #333333; display: block; padding: 8.5px; margin: 0 0 9px; font-size: 16px; line-height: 18px; background-color: #f5f5f5; border: 1px solid rgba(0, 0, 0, 0.15); -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; white-space: pre; white-space: pre-wrap; word-break: break-all; word-wrap: break-word; }

Problem Statement

You are given a string tt and a set SS of NN different strings. You need to separate tt such that each part is included in SS.

For example, the following 4 separation methods satisfy the condition when t=ababt = abab and S=a,ab,bS = \\{a, ab, b\\}.

  • a,b,a,ba, b, a, b
  • a,b,aba, b, ab
  • ab,a,bab, a, b
  • ab,abab, ab

Your task is to count the number of ways to separate tt. Because the result can be large, you should output the remainder divided by 1,000,000,0071{,}000{,}000{,}007.


Input

The input consists of a single test case formatted as follows.

NN s_1s\_1 vdots\\vdots s_Ns\_N tt

The first line consists of an integer N(1leNle100,000)N \\ (1 \\le N \\le 100{,}000) which is the number of the elements of SS. The following NN lines consist of NN distinct strings separated by line breaks. The ii-th string s_is\_i represents the ii-th element of SS. s_is\_i consists of lowercase letters and the length is between 11 and 100,000100{,}000, inclusive. The summation of length of s_i(1leileN)s\_{i} \\ (1 \\le i \\le N) is at most 200,000200{,}000. The next line consists of a string tt which consists of lowercase letters and represents the string to be separated and the length is between 11 and 100,000100{,}000, inclusive.

Output

Calculate the number of ways to separate tt and print the remainder divided by 1,000,000,0071{,}000{,}000{,}007.


Sample Input 1

3
a
b
ab
abab

Output for Sample Input 1

4

Sample Input 2

3
a
b
c
xyz

Output for Sample Input 2

0

Sample Input 3

7
abc
ab
bc
a
b
c
aa
aaabcbccababbc

Output for Sample Input 3

160

Sample Input 4

10
a
aa
aaa
aaaa
aaaaa
aaaaaa
aaaaaaa
aaaaaaaa
aaaaaaaaa
aaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Output for Sample Input 4

461695029