import sys
import math
inp = []
for s in sys.stdin:
inp.append(int(s))
inp.pop(0)
for i in range(0, len(inp), 2):
res = sum(
filter(lambda x: int(math.sqrt(x)) ** 2 == x,
range(inp[i], inp[i+1])
))
print("Case {}: {}".format(i//2+1, res))