#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main()
{
int T,totle;
cin>>T;
totle=T;
while(T--)
{ int n,m,sun=0;
cin>>n>>m;
for(int i=n;i<=m;i++)
{
for(int k=0;k<=m;k++)
{
if(k*k==i)
sun+=i;
}
}
cout<<"Case "<<totle-T<<": "<<sun<<endl;
}
return 0;
}