#P7702. [2019年杭电多校]permutation 1
[2019年杭电多校]permutation 1
permutation 1
Problem Description
A sequence of length is called a permutation if and only if it's composed of the first positive integers and each number appears exactly once. Here we define the "difference sequence" of a permutation as . In other words, the length of the difference sequence is and the -th term is Now, you are given two integers . Please find the permutation with length such that the difference sequence of which is the -th lexicographically smallest among all difference sequences of all permutations of length .
Input
The first line contains one integer indicating that there are tests. Each test consists of two integers in a single line.
Output
For each test, please output integers in a single line. Those integers represent a permutation of to , and its difference sequence is the -th lexicographically smallest.
Sample Input
7
3 1
3 2
3 3
3 4
3 5
3 6
20 10000
Sample Output
3 1 2
3 2 1
2 1 3
2 3 1
1 2 3
1 3 2
20 1 2 3 4 5 6 7 8 9 10 11 13 19 18 14 16 15 17 12
Source
2019 Multi-University Training Contest 5