a,b = map(int,input().split()) for i in range(1,a+b+1): if (a+b)%i==0 and (a+i)%b==0 and (i+b)%a==0: print(i) else: print(-1)