You are given an array $$$A$$$ of length $$$n$$$ and two integers $$$M$$$ and $$$K$$$. Determine if there exists a sequence $$$P$$$ that is permutation of $$$A$$$ such that for every consecutive pair, $$$$$$ \begin{aligned} (p_i + p_{i+1}^2) \bmod M = K \notag \end{aligned} $$$$$$ If a valid permutation exists, output any one; otherwise, output $$$-1$$$.
The first line contains three integers $$$n$$$, $$$M$$$, and $$$K$$$, indicating the size of the array, the modulus, and the target value, respectively. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, representing the array $$$A$$$.
If such a permutation exists, print 'YES' in the first line, followed by the permutation in the second line. Otherwise, print 'NO'.
3 10 4 1 2 3
NO
10 1 0 0 0 0 0 0 0 0 0 0 0
YES 0 0 0 0 0 0 0 0 0 0