A - Algorithm Teaching

Languages: C, C++, Java, Python, ... (details)

The Latin American Beginners Regional Contest is coming, and the University of Byteland wants to prepare a team of newly-admitted students to compete. The university has $N$ teachers that can instruct students in the topic of algorithms. Each candidate student must be trained by a single teacher, in a non-empty subset of the algorithms that the teacher knows. For example, if a given teacher knows the two algorithms $\textsf{PRIM}$ and $\textsf{KRUSKAL}$, then the teacher can train a student just on $\textsf{PRIM}$, just on $\textsf{KRUSKAL}$, or on both $\textsf{PRIM}$ and $\textsf{KRUSKAL}$. As you can see, in this case there are three different options for this particular teacher to train a student. In general, a given teacher that knows $A$ different algorithms can train a student in $2^A-1$ different ways. All these $2^A-1$ options can be carried out, because the university has a lot of new students, and there is no limit on the number of students a teacher can train.

The university would like to form a team having as many students as possible. However, each pair of students in the final team must be able to cooperate, which means that each one of them must have been trained on an algorithm that the other hasn't. For example, a student trained on $\textsf{BFS}$ and $\textsf{DFS}$ can cooperate with another student trained on $\textsf{DFS}$ and $\textsf{DIJKSTRA}$, because the first student is trained on $\textsf{BFS}$ while the second student isn't, and the second student is trained on $\textsf{DIJKSTRA}$ while the first student isn't. On the other hand, a student trained on $\textsf{BFS}$ and $\textsf{DFS}$ cannot cooperate with another student trained just on $\textsf{BFS}$, or just on $\textsf{DFS}$, or on both $\textsf{BFS}$ and $\textsf{DFS}$, among others.

Given the set of algorithms that each teacher knows, you must determine the maximum number of students in a team in which every student can cooperate with each other. Recall that each student must be trained by a single teacher, while each teacher can train as many students as needed. For example, if there is just one teacher who knows the algorithms $\textsf{DFS}$, $\textsf{BFS}$ and $\textsf{DIJKSTRA}$, it is possible to prepare a team with up to three students: a first student trained on $\textsf{DFS}$ and $\textsf{BFS}$, a second student trained on $\textsf{DFS}$ and $\textsf{DIJKSTRA}$, and a third student trained on $\textsf{BFS}$ and $\textsf{DIJKSTRA}$.

Input

The first line contains an integer $N$ ($1 \le N \le 100$) indicating the number of teachers. Each of the next $N$ lines describes a teacher with an integer $A$ ($1 \le A \le 10$) representing the number of algorithms the teacher knows, followed by $A$ different non-empty strings of at most $10$ uppercase letters each, indicating the names of the algorithms that teacher knows.

Output

An integer indicating the maximum number of students in a team in which every student can cooperate with each other.

Sample test(s)

Input
1 3 DFS BFS DIJKSTRA
Output
3
Input
2 4 BFS DFS LCA RMQ 2 PRIM KRUSKAL
Output
8
Input
4 3 BFS DFS DIJKSTRA 4 BFS DFS LCA RMQ 3 DIJKSTRA BFS DFS 3 FLOYD DFS BFS
Output
10
Input
1 1 HAVEFUN
Output
1
Input
3 4 FFEK DANTZIG DEMOUCRON FFT 4 PRIM KRUSKAL LCA FLOYD 4 DFS BFS DIJKSTRA RMQ
Output
18