D. Don't Lay a Lie
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
During the holy month of Ramadan in Tunis, Sherlock Holmes and Dr. Watson are visiting the ancient Medina of Tunis. While enjoying Iftar at a traditional restaurant near the Zaytuna Mosque, they stumble upon a mysterious crime occurring within the labyrinthine alleyways.

There are $$$n$$$ residents in the Medina, numbered from $$$1$$$ to $$$n$$$. After the crime, each resident gives exactly one statement during the police interrogation:

Some residents claim innocence, represented as $$$a_i = -1$$$.

Others point fingers at exactly one other resident, represented as $$$a_i = j$$$ ($$$1 \le j \le n, j \ne i$$$).

The local police are overwhelmed by the complexity of the case. As the night progresses and new evidence surfaces from various surveillance cameras in the Medina's narrow streets, the investigators realize that the reliability of witnesses keeps changing.

Sherlock is given $$$q$$$ intelligence reports. Each report states: "Exactly $$$k$$$ residents are telling the truth." For each report, Holmes must determine which residents could possibly be guilty. It is guaranteed that exactly one person committed the crime.

Input

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10,000$$$) — the number of test cases.For each test case:

The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 10^6, 1 \le q \le n$$$).

The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-1 \le a_i \le n, a_i \ne 0, a_i \ne i$$$).

Each of the next $$$q$$$ lines contains a single integer $$$k$$$ ($$$0 \le k \le n$$$).

The sum of $$$n$$$ over all test cases does not exceed $$$10^6$$$. The sum of $$$q$$$ over all test cases does not exceed $$$10^6$$$. It is guaranteed that all queries are distinct.

Output

For each query, output a single line:

First, an integer $$$m$$$ — the number of residents who could be guilty.

Then $$$m$$$ space-separated integers — the IDs of these possible guilty residents in ascending order.

If no resident could be guilty for a given $$$k$$$, simply output 0.

Example
Input
1
5 5
-1 1 2 1 -1
0
1
2
3
4
Output
0
1 5
2 3 4
2 1 2
0
Note

For the first query:

the first person claims he is innocent. Since everyone is lying, that would mean he is actually guilty. However, person 2 says that A is the criminal, which would make person 2's statement true, contradicting the assumption that everyone is lying.

Therefore, this is not a valid scenario and we ignore it.

A suspect is considered possibly guilty only if they appear in at least one valid scenario.