AT_arc206_d [ARC206D] LIS ∩ LDS
Description
Among the elements of a permutation $ P=(P_1,\ldots,P_N) $ of $ (1,\ldots,N) $ , those that satisfy the following condition are called good elements:
- The element can be included in both a longest increasing subsequence and a longest decreasing subsequence of $ P $ .
You are given integers $ N $ and $ K $ . Determine whether there exists a permutation $ P $ of $ (1,\ldots,N) $ such that there are exactly $ K $ good elements, and if it exists, find one.
Answer for $ T $ test cases.
Input Format
The input is given from Standard Input in the following format:
> $ T $ $ \mathrm{case}_1 $ $ \vdots $ $ \mathrm{case}_T $
Each test case is given in the following format:
> $ N $ $ K $
Output Format
Output $ T $ lines.
For the $ i $ -th line, if there does not exist a permutation satisfying the condition for the $ i $ -th test case, output `-1`. If it exists, output one of them in the following format:
> $ P_1 $ $ \ldots $ $ P_N $
If there are multiple solutions satisfying the condition, any of them will be accepted.
Explanation/Hint
### Sample Explanation 1
In the $ 2 $ -nd test case, $ P_4=2 $ and $ P_5=3 $ are good elements.
Indeed, $ (2,3,5) $ is a longest increasing subsequence of $ P $ . Also, $ (7,6,2,1) $ and $ (7, 6, 3, 1) $ are longest decreasing subsequences of $ P $ .
Therefore, in this sample output, $ 2 $ and $ 3 $ are good elements. The other elements are not good elements, so this output satisfies the condition.
In the $ 1 $ -st and $ 3 $ -rd test cases, there does not exist a permutation satisfying the condition. Thus, output `-1`.
### Constraints
- All input values are integers
- $ 1 \leq T \leq 2\times 10^5 $
- $ 1 \leq N \leq 2\times 10^5 $
- $ 0\leq K \leq N $
- The sum of $ N $ over all test cases does not exceed $ 2\times 10^5 $ .