Writing Tasks

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

In 2020, there are CC programming contests held in Indonesia, numbered from 11 to CC. Each contest has zero or more tasks written for the contest. There are AA task authors who can write tasks for these contests, numbered from 11 to AA. The iith task author only likes the set of contests L_i  1,2, ,CL\_i \subseteq \\{1, 2, \dots , C\\}, and only wants to write tasks for contests in L_iL\_i. Each task author cannot write more than one task for the same contest.

There are also TT topics in programming contest tasks, numbered from 11 to TT. For example, topic 1 might be about graph tasks, topic 2 might be about string tasks, and so on. Each task has exactly one topic. The iith task author is familiar with the set of topics F_i 1,2,,TF\_i \subseteq \\{1, 2, \dots , T\\}, and only wants to write tasks about topics in F_iF\_i. Each task author cannot write more than one task about the same topic.

Additionally, each contest also has a syllabus. The jjth contest syllabus contains the set of topics S_j 1,2,,TS\_j \subseteq \\{1, 2, \dots , T\\}, and the topic for the tasks written for the contest must be in S_jS\_j. Each contest cannot have more than one task for the same topic.

You are a programming contest enthusiast in Indonesia. Surprisingly, you observed the following:

  • Each task author likes at most two contests. Similarly, each contest is liked by at most two task authors.
  • Each task author is familiar with at most two topics. Similarly, each topic is familiarized by at most two task authors.
  • Each contest has at most two topics in its syllabus. Similarly, each topic is present in at most two contest syllabuses.

You want to find the maximum total number of tasks that can be written across all contests.

입력

Input begins with a line containing three integers: ACTA C T (1 A,C,T500001 \le A, C, T \le 50 000) representing the number of task authors, contests, and topics, respectively.

The next AA lines each begins with an integer: L_i|L\_i| (0L_i 20 \le |L\_i| \le 2) representing the number of contests that the iith task author likes, followed by L_i|L\_i| integers: L_i\[x]L\_i\[x] (1L_i\[x]C1 \le L\_i\[x] \le C) representing the liked contests. It is guaranteed that the values in L_iL\_i are distinct. It is also guaranteed that for all 1jC1 \le j \le C, the value jj only appears at most twice in _i=1AL_i\bigcup\_{i=1}^{A}{L\_i}.

The next A lines each begins with an integer: F_i|F\_i| (0F_i20 \le |F\_i| \le 2) representing the number of topics that the iith task author is familiar with, followed by F_i|F\_i| integers: F_i\[y]F\_i\[y] (1F_i\[y]T1 \le F\_i\[y] \le T) representing the familiarized topics. It is guaranteed that the values in F_iF\_i are distinct. It is also guaranteed that for all 1kT1 \le k \le T, the value kk only appears at most twice in _i=1AF_i\bigcup\_{i=1}^{A}{F\_i}.

The next CC lines each begins with an integer: S_j|S\_j| (0S_j20 \le |S\_j| \le 2) representing the number of topics in the jjth contest syllabus, followed by S_j|S\_j| integers: S_j\[z]S\_j\[z] (1S_j\[z] T1 \le S\_j\[z] \le T) representing the topics in the syllabus. It is guaranteed that the values in S_jS\_j are distinct. It is also guaranteed that for all 1kT1 \le k \le T, the value kk only appears at most twice in _j=1CS_j\bigcup\_{j=1}^{C}{S\_j}.

출력

Output in a line an integer representing the maximum total number of tasks that can be written across all contests.