x,y = list(map(int,input().split()))

if x % y == 0:

    print((-1))

else:

    print((x*(y+1)))

    
#!/usr/bin/env python3

import sys, math, itertools, collections, bisect

input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')

inf = float('inf') ;mod = 10**9+7

mans = inf ;ans = 0 ;count = 0 ;pro = 1



x,y = list(map(int,input().split()))

if x%y == 0:print((-1))

else: print(x)
x, y = list(map(int, input().split()))
if x % y == 0:
    print((-1))
else:
    print((x * (y + 1)))

#!/usr/bin/env python3
import sys, math, itertools, collections, bisect

input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8")
inf = float("inf")
mod = 10**9 + 7
mans = inf
ans = 0
count = 0
pro = 1
x, y = list(map(int, input().split()))
if x % y == 0:
    print((-1))
else:
    print(x)

+#!/usr/bin/env python3 +import sys, math, itertools, collections, bisect + +input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8") +inf = float("inf") +mod = 10**9 + 7 +mans = inf +ans = 0 +count = 0 +pro = 1 -    print((x * (y + 1))) +    print(x)