CF1823A.characteristic

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

characteristic

Consider an array a1,a2,,ana_1, a_2, \dots, a_n consisting of numbers 11 and 1-1. Define AA-characteristic of this array as a number of pairs of indices 1i<jn1 \le i \lt j \le n, such that aiaj=1a_i \cdot a_j = 1.

Find any array aa with given length nn with AA-characteristic equal to the given value kk.

Input

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

The only line of each test case contains two integers nn and kk (2n1002 \le n \le 100; 0k(n1)n20 \le k \le \frac{(n-1) n}{2}) — the length of required array and required AA-characteristic.

Output

For each test case, if there is no array aa with given AA-characteristic kk, print NO.

Otherwise, print YES and nn numbers 11 and 1-1, which form the required array aa. If there are multiple answers, print any of them.

Note

In the first test case, there is only one pair of different elements in the array, and their product is a1a2=11a_1 \cdot a_2 = -1 \neq 1, hence its AA-characteristic is 00.

In the second test case, there is only one pair of different elements in the array, and their product is a1a2=1a_1 \cdot a_2 = 1, hence its AA-characteristic is 11.

In the third test case, there are three pairs of different elements in the array, and their product are: a1a2=1a_1 \cdot a_2 = -1, a1a3=1a_1 \cdot a_3 = 1, a2a3=1a_2 \cdot a_3 = -1, hence its AA-characteristic is 11.

In the fourth test case, we can show, that there is no array with length 33, which AA-characteristic is 22.

Samples

7
2 0
2 1
3 1
3 2
3 3
5 4
5 5
YES
1 -1 
YES
1 1 
YES
1 -1 1 
NO
YES
1 1 1 
YES
-1 1 -1 1 1 
NO

在线编程 IDE

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