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

if x%y != 0:

  print(x)

else:

  print((-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(x)
else:
    print((-1))

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

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