Bokstavstärningar
문제
Klara has dices with letters written on them. Each die has a letter on each of its sides. By throwing the dice and rearranging them in some arbitrary order, you can make construct a word with letters.
Write a program to count the number of valid words that can be constructed using Klara's dice. You will get a wordlist, that contains all the valid -letter words.
[이미지 1]
Figure 1: An illustration of the first example. Since , each die has three sides. You can also write STOL and MASK, but not NATT or KOST.
입력
The first line of input contains three space-separated integers , and .
The next lines each describe a die. Line will contain letters, the letters on the sides of the :th die.
Finally, there will be lines, the valid words. Each line will contain an -letter word.
All words will only capital letters A-Z.
No letter will appear on more than one side of a die.
출력
Your program should print a single integer: the number of valid words that can be written.
예제
예제 1
4 3 5 TSU NKT KMO LJA KATT NATT STOL MASK KOST
3