33OJ
登录 注册

#P17532. [JAG 2026 Summer Camp #1] Find Iotas

[JAG 2026 Summer Camp #1] Find Iotas

Problem Description

You are given a positive integer NN and a nonnegative integer XX.

Determine whether there exists a sequence A=(A1,A2,…,A2N)A=(A_1,A_2,\ldots,A_{2N}) of length 2N2N satisfying all of the following conditions.

  • Each integer from 11 to NN appears in AA exactly twice.
  • The sequence (1,2,…,N)(1,2,\ldots,N) occurs exactly XX times as a subsequence of AA. In other words, there are exactly XX ways to choose indices 1≤i1<i2<⋯<iN≤2N1\le i_1<i_2<\cdots<i_N\le 2N such that Aij=jA_{i_j}=j (1≤j≤N1\le j\le N).

If such a sequence exists, output one. If multiple such sequences exist, output any one of them.

Input Format

The input consists of multiple test cases in the following format.

T
case_1
case_2
...
case_T

Each test case is given in the following format.

N X

The first line contains an integer TT (1≤T≤2×1051\le T\le 2\times 10^5), the number of test cases.

For each test case, you are given a positive integer NN (1≤N≤2×1051\le N\le 2\times 10^5) and a nonnegative integer XX (0≤X≤10180\le X\le 10^{18}).

The sum of NN over all test cases does not exceed 2×1052\times 10^5.

Output Format

For each test case, if there is no sequence satisfying the conditions, print No on a single line.

Otherwise, print Yes on the first line, and print 2N2N integers A1,A2,…,A2NA_1,A_2,\ldots,A_{2N} representing a sequence satisfying the conditions on the second line.

If there are multiple valid sequences, you may output any of them.

3
2 3
50 1000000000000000000
4 0
Yes
1 2 1 2
No
Yes
4 4 3 3 2 2 1 1