#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char** argv) {
int a,b,t;
int s1[5000];
cin>>t;
for(int i=0;i<t;i++){
cin>>a>>b;
a=(double)a;
b=(double)b;
int n=0,m=0;
for(int j=a;j<=b;j++){
if(sqrt(j)-(int)sqrt(j)==0){
s1[n]=j;
n++;
}
}
for(int k=0;k<n;k++){
m+=(int)s1[k];
}
cout<<"Case "<<i+1<<": "<<m<<endl;
}
return 0;
}