The Dilemmatic Mechanism

0

0 votes
Easy-Medium
Problem

The process of the getting into the the Coders Club in JGEC has become quite complex.

All the students of the four years of undergraduate engineering and the professors would propose a list of students who should be selected.

Any student in atleast three of the five total lists gets to be a member of the prestigious Coders Club.

Find the number of members of the Coders Club.

Input

The first line of input contains T the number of test cases.
The following line of the input contains five integers N1, N2, N3, N4 and N5, where Nj is the number of candidates proposed by zone j, 1 ≤ j ≤ 5. This is followed by five lines of space separated integers. For 1 ≤ j ≤ 5, line j+1 of the input has Nj integers representing the list of candidates proposed by zone j.

Output
The output consists of a single integer denoting the number of students selected.

Constraints
1 ≤ T ≤ 50
1 ≤ Nj ≤ 1000
1 ≤ Candidate Number ≤ 104

Sample Input
1
5 6 4 6 5
12 387 15 162 5
14 162 92 387 7 748
14 5 12 387
17 952 12 92 398 849
14 5 92 12 387
Sample Output
5
Time Limit: 1.5
Memory Limit: 256
Source Limit:
Explanation

There are 5 students who are selected.

Editor Image

?