#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <iomanip>
#include <cmath>

using namespace std;

#define ll long long 

int n,x,k,a,b,c;

bool bitx[32],bitk[32];
int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);

	int t;
	cin >> t;

	for(int tt=1;tt<=t;tt++){
		cout << "Case #" << tt << ": ";

		cin >> n >> x >> k >> a >> b >> c;

		for(int i=0;i<32;i++){
			bitx[i] = (((1<<i)&x) != 0);
			bitk[i] = (((1<<i)&k) != 0);
		}

		double ans = 0.0;
		for(int i=0;i<32;i++){
			double p[2];
			if(bitx[i])
				p[1] = 1.0,p[0] = 0.0;
			else
				p[0] = 1.0,p[1] = 0.0;

			for(int j=0;j<n;j++){
				double n0=0.0, n1=0.0;
				if(bitk[i]){
					n0 += p[0] * (a/100.0);
					n1 += p[1] * (a/100.0);

					n1 += p[1] * (b/100.0) + p[0] * (b/100.0);

					n0 += p[1] * (c/100.0);
					n1 += p[0] * (c/100.0);
				}
				else{
					n0 += p[0] * (a/100.0) + p[1] * (a/100.0);

					n0 += p[0] * (b/100.0);
					n1 += p[1] * (b/100.0);

					n0 += p[0] * (c/100.0);
					n1 += p[1] * (c/100.0);
				}

				p[0] = n0;
				p[1] = n1;
			}

			ans += (1<<i)*p[1];
		}

		cout << fixed << setprecision(10) << ans << "\n";
	}
	return 0;
}