PCK is planning a message game as entertainment for his friend's birthday party.
Five party participants line up in a horizontal line and challenge each other in a message game. If the message is correctly conveyed to the person on the right, the challenge is successful and prizes are given to the five participants. However, in order to convey the message correctly, the speaker and the listener must be able to use a common language.
The party will bring together friends from all over the world, and to estimate the budget for the prizes, PCK decides to calculate the number of ways the participants can line up for the message game to be successful.
Given the number of people attending the party, and a list of languages that each participant can use, write a program to find the number of ways in which the message game can succeed.
The input is given in the following format.
$N$ $info_1$ $info_2$ : $info_N$
The first line gives the number of participants in the party, $N$ ($5 \leq N \leq 200$). In the following $N$ lines, information on the languages available to the $i$th participant is given. The $info_i$ is given in the following format.
$k$ $l_1$ $l_2$ ... $l_k$
$k$ ($1 \leq k \leq 200$) is the number of languages this participant can use. The $l_i$ is the string (two lowercase letters) that represents the languages that this participant can use. However, there is no overlap in the languages available to the same participant (if $i \ne j$, then $l_i \ne l_j$).
Output the number of ways the participants can be lined up for a successful message game on a single line.
5 2 ja en 2 ja en 2 ja en 2 ja en 2 ja en
120
6 1 ja 3 ja en ch 2 en fr 2 ve fr 3 ch ve po 1 po
8