#include "bits/stdc++.h"
using namespace std;
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
int a,b;
cin>>a>>b;
int sum=0;
for(int j=0;j<32;j++){
if(a<=j*j and j*j<=b)
sum+=j*j;
}
cout<<"Case "<<i+1<<": "<<sum<<endl;
}
}