#agc060e. [agc060_e]Number of Cycles

[agc060_e]Number of Cycles

Problem Statement

In this problem, a permutation of (1,2,cdots,N)(1,2,\\cdots,N) is occasionally called just a permutation.

For a permutation a=(a1,a2,cdots,aN)a=(a_1,a_2,\\cdots,a_N), let f(a)f(a) be the number of cycles in aa. More accurately, the value of f(a)f(a) is defined as follows.

  • Consider an undirected graph consisting of NN vertices numbered 11 to NN. For each 1leqileqN1 \\leq i \\leq N, add an edge connecting vertex ii and vertex aia_i. Then, let f(a)f(a) be the number of connected components in this graph.

You are given a permutation P=(P1,P2,cdots,PN)P=(P_1,P_2,\\cdots,P_N) and an integer KK. Determine whether there is a permutation xx that satisfies the following condition, and construct one if it exists.

  • Let yi=Pxiy_i=P_{x_i} to define a permutation yy.
  • Then, f(x)+f(y)=Kf(x)+f(y)=K holds.

For each input file, solve TT test cases.

Constraints

  • 1leqTleq1051 \\leq T \\leq 10^5
  • 2leqNleq2times1052 \\leq N \\leq 2 \\times 10^5
  • 2leqKleq2N2 \\leq K \\leq 2N
  • (P1,P2,cdots,PN)(P_1,P_2,\\cdots,P_N) is a permutation of (1,2,cdots,N)(1,2,\\cdots,N).
  • In each input file, the sum of NN does not exceed 2times1052 \\times 10^5.
  • All numbers in the input are integers.

Input

The input is given from Standard Input in the following format:

TT case1case_1 case2case_2 vdots\\vdots caseTcase_T

Each case is in the following format:

NN KK P1P_1 P2P_2 cdots\\cdots PNP_N

Output

For each case, if no permutation xx satisfies the condition, print No. Otherwise, print your answer in the following format:

Yes x1x_1 x2x_2 cdots\\cdots xNx_N

Each character in Yes or No in the output may be either uppercase or lowercase. If multiple solutions exist, any of them will be accepted.


Sample Input 1

3
3 3
1 3 2
2 2
2 1
4 8
1 2 3 4

Sample Output 1

Yes
2 1 3
No
Yes
1 2 3 4

In the first case, letting x=(2,1,3)x=(2,1,3) makes y=(3,1,2)y=(3,1,2), satisfying f(x)+f(y)=2+1=3f(x)+f(y)=2+1=3.