	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifdef WindCry1
	freopen("C:\\Users\\LENOVO\\Desktop\\in.txt","r",stdin);
#endif
	memset(dp,-1,sizeof dp);
	int T;cin>>T;for(int cas=1;cas<=T;cas++){
		ll a,b;cin>>a>>b;
		m=f(a);
		change(b);
		ll res=dfs(bit.size()-1,0,true);
		cout<<"Case #"<<cas<<": "<<res<<endl;