#include<iostream>
#include<math.h>
using namespace std;
int main(){
int T,a,b,num,ans;
cin>>T;
for(int i = 1;i <= T;i++){
cin>>a>>b;
cout<<"Case "<<i<<": ";
num = 1;
ans = 0;
while(num <= sqrt(b)){
int k = num * num;
if(k >= a)ans += k;
num++ ;
}
cout<<ans<<endl;
}
return 0;
}