#Lutece0084. Binary Operations

Binary Operations

Migrated from Lutece 84 Binary Operations

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

Bob has a sequence of NN integers. They are so attractive, that Alice begs to have a continued part of it(a continued part here also means a continued subsequence). However, Bob only allows Alice to chose it randomly. Can you give the expectation of the result of the bitwise AND, OR, XOR of all the chosen numbers?

Input

First line of the input is a single integer TT(1T501 \leq T \leq 50), indicating there are TT test cases.

The first line of each test case contains a single number NN(1N500001 \leq N \leq 50000).

The second line contains NN integers, indicating the sequence.

All the NN integers are fit in [0,109][0, 10^9].

Output

For each test case, print Case #t: a b c , in which t is the number of the test case starting from 11, aa is the expectation of the bitwise AND, bb is the expectation of OR and cc is the expectation of XOR.

Round the answer to the sixth digit after the decimal point.

Samples

3
2
1 2
3
1 2 3
3
2 3 4
Case #1: 1.000000 2.000000 2.000000
Case #2: 1.333333 2.500000 1.666667
Case #3: 1.833333 4.333333 3.666667

Note

AND is a binary operation, performed on two numbers in binary notation. First, the shorter number is prepended with leading zeroes until both numbers have the same number of digits (in binary). Then, the result is calculated as follows: for each bit where the numbers are both 11 the result has 11 in its binary representation. It has 00 in all other positions.

OR is a binary operation, performed on two numbers in binary notation. First, the shorter number is prepended with leading zeroes until both numbers have the same number of digits (in binary). Then, the result is calculated as follows: for each bit where the numbers are both 00 the result has 00 in its binary representation. It has 11 in all other positions.

XOR is a binary operation, performed on two numbers in binary notation. First, the shorter number is prepended with leading zeroes until both numbers have the same number of digits (in binary). Then, the result is calculated as follows: for each bit where the numbers differ the result has 11 in its binary representation. It has 00 in all other positions.

Resources

Sichuan State Programming Contest 2012