SP7783 COMFUNC - Commuting Functions
Description
Two functions f and g (f, g: X → X) are commuting if and only if f(g(x)) = g(f(x)) for each x in X.
Input Format
The first line of the input file contains the number of test cases. Each test case is described by a line containing a single integer number n — the number of the elements in the value list of a bijective function f (1
Output Format
For each test case, output a single line containing n integer numbers — the value list of function g that commutes with the function f and has the lexicographically smallest value list.