The Sultan of Isketambola wants his chapatis presented in a stack where each chapati has a unique diameter, and each chapati closer to the bottom is larger than the one above. The cook is presented with a shuffled stack, and must sort it into this order by performing 'flips' (reversals) on sections of the stack. Your task is to write a program that specifies a sequence of flips to sort the stack so that the largest chapati is at the bottom and the smallest at the top. Each chapati's diameter is given, and all diameters in the stack are distinct.
A flip consists of inserting a spatula under a chapati and reversing all chapatis above (including that position). The position is specified from the bottom: the chapati at the bottom has position , while the chapati at the top in a stack of has position .
The stack is described by numbers, the diameters from top to bottom.
The first line contains (1 \leq T \leq 1000), the number of test cases. Each test case consists of two lines: the first contains (1 \leq N \leq 30), and the second contains distinct integers ( integer ), which are the diameters of the chapatis from top to bottom.
For each test case, output a line in the format Case #x:, where is the case number (starting from 1), followed by the sequence of flip positions and a final (which indicates the stack is sorted). No flips should be performed after the stack is sorted.
Esempio 1