#include<bits/stdc++.h>
using namespace std;
int main(){
int n,a,b;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a>>b;
int ans=0;
for(int j=1;j<=32;j++){ //因為值不大於1000
if(j*j<a) continue;
if(j*j>b) break;
ans+=j*j;
}
cout<<"Case "<<i<<": "<<ans<<endl;
}
return 0;
}