#include<stdio.h>
#include <math.h>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <bitset>
#include <iostream>
using namespace std;
#define LL long long
void out(LL x)
{
bitset<32>s(x);
cout<<s<<endl;
}
#define cal(x) __builtin_popcountll(x)
int main()
{
freopen("in.txt","r",stdin);
int t=1;
scanf("%d",&t);
for(int ca=1;ca<=t;ca++)
{
LL d,s1,s2;
scanf("%lld%lld%lld",&d,&s1,&s2);
d++;
while(cal(d)<s1||cal(d)>s2)
{
for(int i=0;cal(d)<s1;i++)
{
d|=1ll<<i; //1的数目小就让低位为1
}
for(int i=0;cal(d)>s2;i++)
{
if(d&(1ll<<i))
d+=1ll<<i;//1的数目多就让其进位为0
}
}
printf("Case #%d: %lld\n",ca,d);
}
return 0;
}