Problem: Every December, VK traditionally holds an event for its employees named "Secret Santa". Here's how it happens.
employees numbered from to take part in the event. Each employee is assigned a different employee , to which employee has to make a new year gift. Each employee is assigned to exactly one other employee, and nobody is assigned to themselves (but two employees may be assigned to each other). Formally, all must be distinct integers between and , and for any , must hold.
The assignment is usually generated randomly. This year, as an experiment, all event participants have been asked who they wish to make a gift to. Each employee has said that they wish to make a gift to employee .
Find a valid assignment that maximizes the number of fulfilled wishes of the employees.
Input Format: Each test contains multiple test cases. The first line contains the number of test cases (). Description of the test cases follows.
Each test case consists of two lines. The first line contains a single integer () — the number of participants of the event.
The second line contains integers (; ) — wishes of the employees in order from to .
It is guaranteed that the sum of over all test cases does not exceed .
Output Format: For each test case, print two lines.
In the first line, print a single integer () — the number of fulfilled wishes in your assignment.
In the second line, print distinct integers (; ) — the numbers of employees assigned to employees .
must be equal to the number of values of such that , and must be as large as possible. If there are multiple answers, print any.
Note: In the first test case, two valid assignments exist: and . The former assignment fulfills two wishes, while the latter assignment fulfills only one. Therefore, , and the only correct answer is .