#include<stdio.h>
#include<stdlib.h>
int main(){
int n,i,j,a,b,temp,Case=1,sum=0;
scanf("%d",&n);
while(n--){
scanf("%d %d",&a,&b);
for(j=1 ; j * j<=b ; j++){
if(j * j<a)
continue;
temp=j * j;
sum+=temp;
}
printf("Case %d: %d\n",Case,sum);
Case++;
sum=0;
}
return 0;
}