P8942 Digital Fortress

Background

Brinkhoff shouted loudly, “Of course it’s a password! If it’s not a password, what else could it be? Why else would Ugha give away this ring? Who would engrave a long string of messy letters on a ring?” Fontaine glared at Brinkhoff angrily, making him quiet down. “Uh… guys?” Beck cut in, as if he really did not want to get involved. “You keep saying these are messy letters. I think I should tell you… the letters engraved on this ring are not messy at all. If you look closely, you’ll see that actually, these letters… well… this is Latin.” Everyone at the command console looked at the ring. It read: > Quis custodiet ipsos custiodies. Who will watch the watchers…

Description

A deadly mutated string has passed through the X-11 filter and gone deep into the NSA database. Susan and Beck must crack the password immediately to shut down the worm virus. In the worm’s files, they found some properties of the password: - It has $n$ numbers, each in $[1,m]$, and the sequence is non-decreasing. - If you compute the prefix XOR sums, the prefix XOR sums are also non-decreasing. - If you compute the suffix XOR sums, the suffix XOR sums are still non-decreasing. Besides this, they also found the values of $n,m$. Now they need to construct a password sequence that satisfies all properties. *** #### [Formal statement] Determine whether there exists a non-decreasing positive integer sequence $a$ of length $n$, with all elements in the range $[1,m]$, such that: - $\forall1

Input Format

The first line contains a positive integer $t$, the number of test cases. For each test case, input two positive integers $n,m$.

Output Format

For each test case, if there is no password that meets the requirements, output `No`. Otherwise, output `Yes`, and on the next line output one valid construction.

Explanation/Hint

#### [Sample explanation] For the first test case, the prefix XOR sums are $\{1,7,15,31\}$, and the suffix XOR sums are $\{16,24,30,31\}$. Both are increasing sequences, so the requirements are satisfied. For the second test case, there is no valid construction. #### [Constraints] **This problem uses bundled testdata.** |$\text{Subtask}$|Score|$n\le$|$m\le$| |:-:|:-:|:-:|:-:| |$0$|$10$|$5$|$200$| |$1$|$30$|$20$|$10^6$| |$2$|$60$|$10^5$|$2^{63}-1$| For $100\%$ of the testdata, $1\le n\le10^5$, $1\le m\le2^{63}-1$, $1\le t\le50$. Translated by ChatGPT 5