#K73872. Identify Duplicate Teams with Duplicate Participants

    ID: 34072 Type: Default 1000ms 256MiB

Identify Duplicate Teams with Duplicate Participants

Identify Duplicate Teams with Duplicate Participants

In this problem, you are given multiple test cases. Each test case contains several teams, where each team is represented by its name followed by a list of its participants. A participant is allowed to belong to only one team. If a participant appears in more than one team within the same test case, then every team having that participant is considered to have a duplicate participant.

Formally, for each test case, you are given an integer (T) denoting the number of test cases. For each test case, the first line contains an integer (N) representing the number of teams. The following (N) lines contain the team's information: the first token is the team's name and the subsequent tokens are the names of the participants. Your task is to print, for each test case, the names of all teams (in lexicographical order) that share at least one participant with another team. If there are no duplicates, output "No duplicates". For multiple test cases, separate outputs by a blank line.

inputFormat

The input starts with an integer (T) representing the number of test cases. Each test case starts with an integer (N) (the number of teams). This is followed by (N) lines, each containing the team's name and the names of its participants separated by spaces.

outputFormat

For each test case, if there exists any participant registered in more than one team, output all corresponding team names in lexicographical order, one per line. If no duplicate participant exists, output "No duplicates". Separate the outputs of consecutive test cases by a blank line.## sample

1
3
TeamA Alice Bob Charlie
TeamB Dave Eve Bob
TeamC Frank Alice
TeamA

TeamB TeamC

</p>