Champion Sort (Small)

Compute the minimum expected number of random subset shuffles that sorts a permutation of 1 to N into increasing order.

Hard8ProbabilityCombinatoricsMathNo attempts yetTime limit5sMemory limit512 MB

Problem

Here is a man who sorts in a very unusual way.

And his name is John Cena!!!!

CENA.png

John Cena is no algorithm expert, so he sorts numbers his own way. The array he sorts holds each natural number from 11 to NN exactly once. First he picks a few elements of the array and shouts "You can't see me". Then he hits every picked element with a Five Knuckle Shuffle at the same time. The picked elements take heavy damage and their order becomes random: if he picked kk elements, all k!k! arrangements of those elements over those kk positions come out with equal probability.

Before each shuffle John Cena looks at the current array and then decides what to pick next. He wants to minimize the expected number of Five Knuckle Shuffles needed until the array is sorted in increasing order. Shuffles thrown at the same time count as one. Find that minimum expected value.

Input

The first line has the number of test cases TT. Each test case takes two lines. The first line has the length of the array NN, and the second line has the elements of the array in order.

1T1001 \le T \le 100 and 1N101 \le N \le 10. The array holds each natural number from 11 to NN exactly once.

Output

For each test case print one line in the form Case #x: y, where xx is the test case number and yy is the minimum expected value. Print yy rounded to six digits after the decimal point.

Hint

In case #1 of the first example John Cena picks both elements. With probability 1/21/2 the array becomes sorted and with probability 1/21/2 it stays as it is, so the expected value is 2.

In case #2 he picks 3 and 2. For the same reason as case #1 the expected value is 2.

In case #3 he picks 2 and 1, then picks 4 and 3. Each of the two costs 2 in expectation, so the total is 4.