CF2107A.LRC and VIP

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

LRC and VIP

You have an array aa of size nna1,a2,ana_1, a_2, \ldots a_n.

You need to divide the nn elements into 22 sequences BB and CC, satisfying the following conditions:

  • Each element belongs to exactly one sequence.
  • Both sequences BB and CC contain at least one element.
  • gcd\gcd $(B_1, B_2, \ldots, B_{|B|}) \ne \gcd(C_1, C_2, \ldots, C_{|C|})$ ^{\text{∗}}

^{\text{∗}}gcd(x,y)\gcd(x, y) denotes the greatest common divisor (GCD) of integers xx and yy.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t5001 \le t \le 500). The description of the test cases follows.

The first line of each test case contains an integer nn (2n1002 \le n \le 100).

The second line of each test case contains nn integers a1,a2,,ana_1,a_2,\ldots,a_n (1ai1041 \le a_i \le 10^4).

Output

For each test case, first output Yes if a solution exists or No if no solution exists. You may print each character in either case, for example YES and yEs will also be accepted.

Only when there is a solution, output nn integers on the second line. The ii-th number should be either 11 or 22. 11 represents that the element belongs to sequence BB and 22 represents that the element belongs to sequence CC.

You should guarantee that 11 and 22 both appear at least once.

Note

In the first test case, B=[51,9]B = [51, 9] and C=[1,20]C = [1, 20]. You can verify gcd(B1,B2)=31=gcd(C1,C2)\gcd(B_1, B_2) = 3 \ne 1 = \gcd(C_1, C_2).

In the second test case, it is impossible to find a solution. For example, suppose you distributed the first 33 elements to array BB and then the last element to array CC. You have B=[5,5,5]B = [5, 5, 5] and C=[5]C = [5], but gcd(B1,B2,B3)=5=gcd(C1)\gcd(B_1, B_2, B_3) = 5 = \gcd(C_1). Hence it is invalid.

Samples

3
4
1 20 51 9
4
5 5 5 5
3
1 2 2
Yes
2 2 1 1
No
Yes
1 2 2

在线编程 IDE

建议全屏模式获得最佳体验