Number game

Time Limit: 1000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 3043
64-bit integer IO format: %I64d      Java class name: Main

Description

One day, QQ is playing a number game. He first sorts the N numbers 1, 2, 3…n, but this is too easy. So long1 wants to challenge QQ’s skill, he let the number sequence becomes wavy. For example, a1<a2>a3<a4>a5… or a1>a2<a3>a4<a5….
Now long1 sorts these wavy sequences by lexicographic order, and he wants to know what the M-th sequence is when you have N numbers.
As an Acmer, long1 thinks you can solve it and gives him the answer.

Input

There are many test cases:
For every case:

First line is the number of case
The next case lines:
Every line contains two numbers N, and M.(1<=N<=20,M is not larger than the number of wavy sequences)

Output

For every case, output the sequence.

Sample Input

2 
2 1 
3 3

Sample Output

1 2 
2 3 1

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .