#D7806. Separate String
Separate String
Separate String
You are given a string and a set of different strings. You need to separate such that each part is included in .
For example, the following 4 separation methods satisfy the condition when and .
Your task is to count the number of ways to separate . Because the result can be large, you should output the remainder divided by .
Input
The input consists of a single test case formatted as follows.
:
The first line consists of an integer () which is the number of the elements of . The following lines consist of distinct strings separated by line breaks. The -th string represents the -th element of . consists of lowercase letters and the length is between and , inclusive. The summation of length of () is at most . The next line consists of a string which consists of lowercase letters and represents the string to be separated and the length is between and , inclusive.
Output
Calculate the number of ways to separate and print the remainder divided by .
Examples
Input
3 a b ab abab
Output
4
Input
3 a b c xyz
Output
0
Input
7 abc ab bc a b c aa aaabcbccababbc
Output
160
Input
10 a aa aaa aaaa aaaaa aaaaaa aaaaaaa aaaaaaaa aaaaaaaaa aaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Output
461695029
inputFormat
outputFormat
output the remainder divided by .
Input
The input consists of a single test case formatted as follows.
:
The first line consists of an integer () which is the number of the elements of . The following lines consist of distinct strings separated by line breaks. The -th string represents the -th element of . consists of lowercase letters and the length is between and , inclusive. The summation of length of () is at most . The next line consists of a string which consists of lowercase letters and represents the string to be separated and the length is between and , inclusive.
Output
Calculate the number of ways to separate and print the remainder divided by .
Examples
Input
3 a b ab abab
Output
4
Input
3 a b c xyz
Output
0
Input
7 abc ab bc a b c aa aaabcbccababbc
Output
160
Input
10 a aa aaa aaaa aaaaa aaaaaa aaaaaaa aaaaaaaa aaaaaaaaa aaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Output
461695029
样例
3
a
b
ab
abab
4