#include <bits/stdc++.h>

using namespace std;

int n;
int a[50100];
int preor[50],preand[50];
int g[50][3],bo[50];

int main(){
	int T;
	scanf("%d",&T);
	for (int ti=1;ti<=T;ti++){
		scanf("%d",&n);
		for (int i=1;i<=n;i++) scanf("%d",&a[i]);

		long long t1,t2,t3;
		long long m=(long long)(n+1)*n/2;
		t1=t2=t3=0;
		
		memset(bo,0,sizeof(bo));
		memset(g,0,sizeof(g));
		memset(preor,0,sizeof(preor));
		memset(preand,0,sizeof(preand));
		for (int i=0;i<30;i++) g[i][0]=1;

		for (int ii=1;ii<=n;ii++){
			int now=a[ii];
			for (int i=0;i<30;i++){
				long long k=1<<i;
				if ((now>>i)&1){
					//and
					t1+=k*(ii-preand[i]);
					//or
					t2+=k*ii;
					preor[i]=ii;
					//xor
					bo[i]=1-bo[i];
				}else{
					//and
					preand[i]=ii;
					//or
					t2+=k*preor[i];
					//xor
				}
				g[i][bo[i]]++;
				t3+=k*g[i][1-bo[i]];
			}
			//cout << t1<<" "<<t2<<" "<<t3<<endl;
		
		}
		printf("Case #%d: %.6f %.6f %.6f\n",ti,t1*1.0/m,t2*1.0/m,t3*1.0/m);
	}
	return 0;
}

