#include <iostream>
#include<cmath>
using namespace std;
int main(){
int a,b,n,i = 1,sum = 0;
cin >> n;
while(i <= n){
sum = 0;
cin >> a >> b;
int temp1,temp2;
temp2 = sqrt(b);
if(sqrt(a)==(int)sqrt(a)){
temp1 = sqrt(a);
}else{
temp1 = sqrt(a) + 1;
}
for(int j = temp1;j <= temp2;j++){
sum = sum + j * j;
}
cout <<"Case "<< i <<": "<< sum <<endl;
i++;
}
}