| Codeforces Round 1082 (Div. 1) |
|---|
| Finished |
There are $$$2n$$$ cards with numbers $$$1,1,2,2,\ldots,n,n$$$ written on them. In other words, for all $$$j=1,2,\ldots,n$$$, there are exactly $$$2$$$ cards with the number $$$j$$$. Each card only has one number written on its front.
You will play a card flipping game. Initially, all $$$2n$$$ cards are placed on their back (the side without numbers). In each turn, you flip exactly two cards. If the two cards have the same number, you discard the two cards. Otherwise, you flip them back to their original position. You win when all $$$2n$$$ cards are discarded. Note that you do not have to flip the two cards simultaneously, so you can decide on your choice of the second card after seeing the number on the first one.
Consider the following "greedy" algorithm to play the game. Initially, the $$$2n$$$ cards are placed in a row arbitrarily. Then your strategy on each turn is as follows:
It can be shown that the algorithm's strategy is uniquely determined on every turn.
You must solve the following problem regarding the algorithm stated above.
Additionally, if such an orientation does not exist, please report so.
$$$^{\text{∗}}$$$Here, "the first card" of some condition refers to the earliest card in the row satisfying that condition.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). The description of the test cases follows.
The only line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 300\,000$$$, $$$1 \le k \le 1\,000\,000$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$300\,000$$$.
If there is an orientation of cards that satisfies the conditions, output "YES" on a new line.
Then, output $$$2n$$$ integers $$$a_1,a_2,\ldots,a_{2n-1},a_{2n}$$$ on the next line. Here, $$$a_i$$$ is the number written on the $$$i$$$-th card.
Do note that the sequence $$$a$$$ must satisfy the following conditions:
If there are multiple solutions, print any of them.
If there is no orientation of cards that satisfies the conditions, output "NO" on a separate line.
You can output the answer in any case. For example, the strings "yEs", "yes", and "Yes" will also be recognized as positive responses.
62 33 43 23 56 106 67
YES 2 1 2 1 YES 1 3 2 2 1 3 NO YES 1 2 3 1 2 3 YES 2 1 3 4 5 4 1 2 6 5 6 3 NO
For the first test case, the choices on each turn are as follows:
Here, the red numbers indicate the cards flipped on the current turn, and the blue numbers indicate cards that you have flipped previously.
For the fourth test case, the choices on each turn are as follows:
The algorithm took exactly $$$k=5$$$ turns to win the game.
| Name |
|---|


