#C1316. Finding Common Friends

    ID: 42667 Type: Default 1000ms 256MiB

Finding Common Friends

Finding Common Friends

You are given T test cases. In each test case, you are provided with two lists of integers, representing the IDs of two users' friends. Your task is to determine the common friends that exist in both lists. The result for each test case should be the sorted list of common friend IDs. If there are no common friends between the two lists, output "No common friends" instead.

Each test case's output must begin with a header line in the format Test Case i: (where i starts from 1), followed by a new line containing either the sorted common friend IDs separated by spaces, or the message "No common friends" if there is no intersection.

Note: Even if the lists contain duplicate numbers, treat them as sets (ignore duplicates).

inputFormat

The first line of input contains a single integer T, representing the number of test cases.

For each test case, there are two lines:

  • The first line contains a sequence of integers (space separated) representing the first friend's list.
  • The second line contains a sequence of integers (space separated) representing the second friend's list.

There is no fixed length for each list.

outputFormat

For each test case, output two lines:

  • The first line must be of the form Test Case i: where i is the test case number starting from 1.
  • The second line should either list the common friend IDs in ascending order separated by a space, or print No common friends if there are none.
## sample
2
1 2 3
2 3 4
5 6 7 8
8 9 10 7 6
Test Case 1:

2 3 Test Case 2: 6 7 8

</p>