A Decorative Fence

No attempts yetTime limit1sMemory limit128 MB

Problem

Richard has just finished building his new house. The only thing the house still lacks is a cute little wooden fence. Having no idea how to build one himself, he decided to order it. He somehow got hold of the ACME Fence Catalogue 2002, the ultimate resource on cute little wooden fences, and after reading its preface he already knew what makes a little wooden fence cute.

A wooden fence consists of $N$ wooden planks placed vertically in a row, next to one another. A fence is cute if and only if both of the following conditions hold:

  • The planks all have different lengths, namely $1, 2, \dots, N$ plank-length units.
  • Every plank that has two neighbours is either larger than both of its neighbours or smaller than both of them. (This makes the top of the fence rise and fall alternately.)

It follows that every cute fence of $N$ planks can be described uniquely by a permutation $a_1, \dots, a_N$ of the numbers $1, \dots, N$ such that $(a_i - a_{i-1}) \cdot (a_i - a_{i+1}) > 0$ for every $i$ with $1 < i < N$; and, conversely, every such permutation describes a cute fence.

There are of course many different cute wooden fences made of $N$ planks. To impose an order on the catalogue, the sales manager decided to sort them as follows: fence $A$ (permutation $a_1, \dots, a_N$) comes before fence $B$ (permutation $b_1, \dots, b_N$) in the catalogue if and only if there exists an index $i$ such that $a_j = b_j$ for all $j < i$ and $a_i < b_i$. (In other words, take the two permutations, find the first position at which they differ, and compare the values there.) All cute fences of $N$ planks are numbered, starting from $1$, in the order in which they appear in the catalogue; this number is called their catalogue number.

All cute fences made of $N = 4$ planks, ordered by their catalogue numbers.

After carefully examining every cute little wooden fence, Richard ordered some of them. For each one he wrote down its number of planks and its catalogue number. Later, when he met his friends, he wanted to show them the fences he had ordered, but he had lost the catalogue somewhere. All he has left are his notes. Please help him work out what his fences look like.

Input

The first line of the input contains the number $K$ ($1 \le K \le 100$) of data sets. $K$ lines follow, each describing one data set.

Each of these $K$ lines contains two integers $N$ and $C$ ($1 \le N \le 20$), separated by a space. $N$ is the number of planks in the fence and $C$ is the fence's catalogue number.

You may assume that the total number of cute fences made of $N = 20$ planks fits into a signed 64-bit integer. You may also assume that the input is always valid; in particular, $C$ is at least $1$ and never exceeds the number of cute fences of $N$ planks.

Output

For each data set, output a single line describing the $C$-th fence of $N$ planks in the catalogue. More precisely, if the fence is described by the permutation $a_1, \dots, a_N$, then the corresponding line must contain the numbers $a_i$ in the correct order, separated by single spaces.