SOLVE
LATER
You are given a string $$S$$ of length $$N$$ having distinct lowercase alphabetic characters. Each character in the string $$S$$ has some follow-up characters. The follow-up character denotes what characters can follow a particular character that belongs to the string $$S$$. Note that the follow-up characters belong to the string $$S$$.
Now you have to pick one of the characters of the string $$S$$ 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 $$M$$ length strings that can be made out of the characters of the string $$S$$. Since the number could be very large output it modulo $$10^9 + 9$$.
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 $$N$$, the length of the string.
The second line of the input contains a string $$S$$ of length $$N$$.
Then $$N$$ lines follow, $$i$$-th $$(1 \le i \le N)$$ line contains a string $$T_i$$ where each character in the string is a follow up character of the $$i$$-th character in the main string $$S$$.
The last line contains a single integer $$M$$, 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 $$M$$ length strings modulo $$10^9 + 9$$.
Constraints
$$1 \le N \le 10$$
$$1 \le |T_i| \le N$$
$$1 \le M \le 5$$ x $$10^5$$
Follow ups:
$$a : [b]$$
$$b : [a, c]$$
$$c : [a, b, d]$$
$$d : [a, d]$$
Few strings of length $$3$$ and thier non-empty subsequences:
$$aba : [a, b, a, ab, aa, ba, aba]$$
$$abc : [a, b, c, ab, ac, bc, abc]$$
$$dda : [d, d, a, dd, da, da, dda]$$
and so on...
Note that, there are $$98$$ such non-empty subsequences.