#K85807. Analyzing Intersections in Groups

    ID: 36723 Type: Default 1000ms 256MiB

Analyzing Intersections in Groups

Analyzing Intersections in Groups

You are given one or more test cases. In each test case, there are several groups, and each group is identified by a unique identifier along with a list of integer values. Your task is to determine the number of unique elements that are common between every pair of groups within each test case.

For each pair of groups, output a line in the format:

\(\texttt{Group }i\texttt{ - Group }j\texttt{: }k\)

where \(i\) and \(j\) are the identifiers of the two groups and \(k\) is the count of unique common values between them.

Note: Read input from stdin and write output to stdout.

inputFormat

The first line contains an integer \(T\), the number of test cases.

For each test case:

  • The first line contains an integer \(G\) denoting the number of groups.
  • For each group, there are two lines:
    • The first line contains two integers: the group identifier and the number of values \(n\) in that group.
    • The next line contains \(n\) space-separated integers representing the values in the group.

All input is given via stdin.

outputFormat

For every pair of groups in each test case, output a line in the format:

Group i - Group j: k

where i and j are the group identifiers, and k is the number of unique values common to both groups. The output should be printed to stdout.

## sample
2
3
1 5
10 20 30 40 50
2 4
30 50 70 90
3 3
50 100 150
2
1 4
5 10 15 20
2 3
10 15 25
Group 1 - Group 2: 2

Group 1 - Group 3: 1 Group 2 - Group 3: 1 Group 1 - Group 2: 2

</p>