- Time limit: 1.00 s
- Memory limit: 512 MB
Let denote the th permutation (in lexicographical order) of . For example, and .
Your task is to process two types of tests:
- Given and , find
- Given and , find
Input
The first line has an integer : the number of tests.
Each test is either "1 " or "2 ".
Output
For each test, print the answer according to the example.
Constraints
Example
Input:
6 1 4 1 1 4 2 2 4 1 2 3 4 2 4 1 2 4 3 1 5 42 2 5 2 4 5 3 1
Output:
1 2 3 4 1 2 4 3 1 2 2 4 5 3 1 42