#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int pow(int a); //計算平方
int main()
{
int x;
while (cin >> x)
{
int a, b,lenght=0,lenght2=0;
int res[1000];
int out[100];
int n=0;
for (int i = 0; i < x; i++)
{
cin >> a >> b;
res[0 + i*2] = a;
res[1 + i*2] = b;
lenght = lenght + 1;
}
for (int i = 0; i < lenght; i++)
{
for (int j = 0; j < res[1 + i * 2]; j++)
{
if (res[0 + i * 2] <= pow(j) && res[1 + i * 2] >= pow(j))
{
n = n + pow(j);
}
}
out[i] = n;
n = 0;
cout << "Case " << i+1 << ": " << out[i] << endl;
}
}
}
int pow(int a)
{
a = a * a;
return a;
}