A permutation of length is an array of integers such that every integer from to (inclusive) appears in it exactly once. For example, is a permutation of length .
A subsegment of an array ] is called good if the subsegment is a permutation of length . For example, the array contains good subsegments: .
You are given two integers and . Find a permutation of length such that it contains exactly good subsegments. Print -1
if no such permutation exists.
Input Format
- The first line contains an integer , denoting the number of test cases. The test cases then follow:
- The first and only line of each test case contains two space-separated integers .
Output Format
For each test case, output a single line containing the answer:
- If no permutation satisfies the given conditions, print
−1
. - Otherwise, print space-separated integers , denoting the elements of the permutation. If there are multiple answers, you can output any of them.
Constraints
- Sum of over all test cases does not exceed .
Subtasks
- Subtask 1 (100 points): Original constraints
Sample Input 1
4
1 1
3 2
4 1
5 3
Sample Output 1
1
1 3 2
-1
5 3 1 4 2
Explanation
Test case : The only permutation of length is , which contains one good subsegment .
Test case : The permutation contains good subsegments: , .
Test case : There is no way to construct a permutation of length which contains one good subsegment.
Test case : The permutation contains good subsegments: . There are other permutations of length having good subsegments.
Solution:
This question solution is updated within contest time. please click on follow button and subscribe our channel.if you follow and subscribe our channel then get notification of answer as soon as possible.
No comments:
Post a Comment