#P11445. Counting Naughty Students

    ID: 13525 Type: Default 1000ms 256MiB

Counting Naughty Students

Counting Naughty Students

In a rating competition held once every semester, each student in the class is allowed to rate the teacher of one subject among Chinese, Math, and English. Ideally, every student should rate exactly one teacher. However, some students, being mischievous, either rate more than one teacher or do not rate any teacher at all. Given the rating details for the three subjects' teachers in Xiaoshan's class, count the number of mischievous students.

Input details: The first line contains an integer n, the number of students (each student is identified by an integer from 1 to n). The following three lines describe the rating records for Chinese, Math, and English teachers respectively. Each subject's record begins with an integer k (the number of ratings), followed by k space-separated integers representing the student IDs who rated that teacher.

Mathematically, if R(i) denotes the total number of ratings given by student i across the subjects, then student i is considered mischievous if R(i) \neq 1. Your task is to count how many students satisfy this condition.

inputFormat

The input consists of four lines:

  1. An integer n representing the total number of students</em>.
  2. For the Chinese teacher: an integer k1 followed by k1 integers (student IDs).
  3. For the Math teacher: an integer k2 followed by k2 integers (student IDs).
  4. For the English teacher: an integer k3 followed by k3 integers (student IDs).

outputFormat

Output a single integer representing the number of mischievous students (those who rated either none or more than one teacher).

sample

5
2 1 2
2 2 3
1 4
2

</p>