P9591 "PFLOI R1" PFL Transformation

Background

Five top experts have gathered here, and sparks of ideas collide fiercely. Soon, PFLOI Round 1 is ready. It begins...

Description

A new journey has begun: Zhili has set out to look for bananas. There are a total of $n$ bananas on the road, numbered from $1$ to $n$. Seeing such delicious food, Zhili is very excited. However, Zhili does not want to eat too much or too little, so it will eat **exactly** $m$ bananas. Zhili is very picky. It will only be satisfied if the XOR sum of the indices of the $m$ bananas it eats is **exactly** $2^{\lfloor\log_2 n\rfloor+1}-1$. Please help find which bananas it should eat to make it satisfied. If Zhili's requirement cannot be satisfied no matter what, please output `-1`. ------------ **Formal statement**: Please choose $m$ numbers from $1$ to $n$ such that their XOR sum is exactly $2^{\lfloor\log_2 n\rfloor+1}-1$. If there is no solution, output `-1`.

Input Format

**This problem has multiple test cases**. The first line contains an integer $T$, meaning there are $T$ test cases in total. For each test case, each line contains two integers $n$ and $m$, with meanings as described in the statement.

Output Format

For each test case, if there is a solution, output one line with $m$ integers, representing the $m$ numbers you choose. If there is no solution, output `-1`. **This problem uses Special Judge**. If there are multiple possible solutions, you may output any one of them.

Explanation/Hint

**This problem does not use bundled tests**. | Test Point ID | Special Property | Score | | :----------: | :----------: | :-----:| | $1,2$ | $n\le15$ | $2\times4=8$ | | $3\sim11 $ | $n\le128$ | $9\times3=27$ | | $12\sim24 $ | $\sum n\le10^5$ | $13\times3=39$ | | $25\sim29$ | No special restrictions | $5\times4=20$ | | $30$ | No special restrictions | $1\times6=6$ | Constraints: For all testdata, $1\le m\le n\le10^6$, $1\le\sum n,T\le10^6$. Translated by ChatGPT 5