https://www.acmicpc.net/problem/1977
m=int(input())
n=int(input())
min=n
num=0
i=1
while 1:
if i*i>=m and i*i<=n:
num+=i*i
if i*i<=min:
min=i*i
if i*i>n:
break
i+=1
if num==0:
print("-1")
else:
print(num)
print(min)