You are given a string of length having distinct lowercase alphabetic characters. Each character in the string has some follow-up characters. The follow-up character denotes what characters can follow a particular character that belongs to the string . Note that the follow-up characters belong to the string .
Now you have to pick one of the characters of the string and mark it as a start character. After you pick one character, you need to look in its follow-up list and choose one character from it and continue this to form a new string.
Now, you have to count the total number of non-empty subsequences of all the possible length strings that can be made out of the characters of the string . Since the number could be very large output it modulo .
Note: Carefully check out the sample explanation for a better understanding of the problem.
Input Format
The first line of the input contains a single integer , the length of the string.
The second line of the input contains a string of length .
Then lines follow, -th line contains a string where each character in the string is a follow up character of the -th character in the main string .
The last line contains a single integer , length of the string that has to be constructed.
Output Format
The only line of the output contains a single integer, the total number of non-empty subsequences of all the possible length strings modulo .
Constraints
x
Follow ups:
Few strings of length and thier non-empty subsequences:
and so on...
Note that, there are such non-empty subsequences.