#P1205F. Beauty of a Permutation
Beauty of a Permutation
No submission language available for this problem.
Description
Define the beauty of a permutation of numbers from to as number of pairs such that and numbers are consecutive numbers in some order. For example, the beauty of the permutation equals , and segments, corresponding to pairs, are , , , , , , , , .
Answer independent queries. In each query, you will be given integers and . Determine if there exists a permutation of numbers from to with beauty equal to , and if there exists, output one of them.
The first line contains a single integer () — the number of queries.
Follow lines. Each line contains two integers , (, ) — the length of permutation and needed beauty respectively.
For a query output "NO", if such a permutation doesn't exist. Otherwise, output "YES", and in the next line output numbers — elements of permutation in the right order.
Input
The first line contains a single integer () — the number of queries.
Follow lines. Each line contains two integers , (, ) — the length of permutation and needed beauty respectively.
Output
For a query output "NO", if such a permutation doesn't exist. Otherwise, output "YES", and in the next line output numbers — elements of permutation in the right order.
Samples
Note
Let's look at the first example.
The first query: in there is only one segment consisting of consecutive numbers — the entire permutation.
The second query: in there are such segments: , , , , , .
There is no such permutation for the second query.
The fourth query: in there are such segments: , , , , , , , , , .