------
## 最终结论
```python
from itertools import permutations

def is_good_permutation(p):
    n = len(p)
    marked = [False] * n
    decomposition = []

    for i in range(n):
        if not marked[i]:
            cycle = []
            x = i
            while not marked[x]:
                cycle.append(x + 1)
                marked[x] = True
                x = p[x] - 1
            
            max_index = cycle.index(max(cycle))
            cycle = cycle[max_index:] + cycle[:max_index]
            decomposition.append(cycle)

    decomposition.sort(key=lambda x: x[0])
    new_perm = [elem for sublist in decomposition for elem in sublist]
    
    return new_perm == p

def find_kth_good_permutation(n, k):
    all_perms = permutations(range(1, n + 1))
    
    good_perms = []
    
    for perm in all_perms:
        if is_good_permutation(list(perm)):
            good_perms.append(list(perm))
            if len(good_perms) == k:
                return good_perms[-1]
    
    return -1

def main():
    import sys
    input = sys.stdin.read
    data = input().split()
    
    t = int(data[0])
    
    index = 1
    results = []
    
    for _ in range(t):
        n, k = int(data[index]), int(data[index + 1])
        index += 2
        
        result = find_kth_good_permutation(n, k)
        
        if result == -1:
            results.append("-1")
        else:
            results.append(" ".join(map(str, result)))
    
    print("\n".join(results))

if __name__ == "__main__":
    main()
```