K. Kilani & Ayoub hate (Gold)
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Ayoub gave Kilani an array $$$a$$$ of length $$$n$$$, where each element satisfies $$$1 \le a_i \le n$$$. The elements of $$$a$$$ are not necessarily distinct.

He may reorder (permute) the elements of the array in any way he wants. After choosing an ordering, he constructs an undirected graph with $$$n$$$ vertices labeled $$$1$$$ to $$$n$$$, and for each index $$$i$$$, he adds an edge between vertex $$$i$$$ and vertex $$$a_i$$$.

Self-loops (when $$$i = a_i$$$) and multiple edges are allowed.

Determine whether there exists a reordering of the array such that the resulting graph is connected.

Input

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

For each test case:

  • The first line contains a single integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the array.
  • The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le n$$$).

It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$3 \cdot 10^5$$$.

Output

For each test case:

  • If it is impossible to reorder the array so that the resulting graph is connected, print NO.
  • Otherwise, print YES on the first line, and on the second line print $$$n$$$ integers — a reordering of the array $$$a_1, a_2, \dots, a_n$$$ such that if we add an undirected edge between $$$i$$$ and $$$a_i$$$ for every $$$i$$$, the resulting graph is connected.
Example
Input
4
1
1
2
1 2
4
4 4 4 4
5
1 2 3 4 5
Output
Yes
1
Yes
2 1
Yes
4 4 4 4
Yes
2 3 4 5 1