C. Construct Permutation
time limit per test
3 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

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$$$.

Input

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$$$.

  • $$$2 \leq n \leq 2\times10^5$$$
  • $$$1 \leq M \leq 10^9$$$
  • $$$0 \leq a_i, K \lt M$$$
Output

If such a permutation exists, print 'YES' in the first line, followed by the permutation in the second line. Otherwise, print 'NO'.

Examples
Input
3 10 4
1 2 3
Output
NO
Input
10 1 0
0 0 0 0 0 0 0 0 0 0
Output
YES
0 0 0 0 0 0 0 0 0 0