AtCoder Petrozavodsk Contest 001 - Two Integers

You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.

Constraints

* 1 ≤ X,Y ≤ 10^9
* X and Y are integers.

Input

Input is given from Standard Input in the following format:


X Y


Output

Print a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.

Examples

Input

8 6


Output

16


Input

3 3


Output

-1

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

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


(a, b) = map(int, input().split())
ans = -1
for i in range(1, 4):
	if a * i % b != 0:
		ans = a * i
print(ans)


(x, y) = map(int, input().split())
print((x + 1) * (x % y > 0) - 1)


(A, B) = map(int, input().split())
if A % B == 0:
	print(-1)
	exit()
else:
	print(A)


(X, Y) = map(int, input().split())
if X < Y or not X % Y == 0:
	print(X)
else:
	print(-1)


(a, b) = map(int, input().split())
print(-1 if a % b == 0 else a)


(x, y) = (int(i) for i in input().split())
if x % y == 0:
	print(-1)
else:
	print(x)


(X, Y) = map(int, input().split())
if X % Y == 0:
	print(-1)
else:
	print(X * Y - X)


(n, m) = map(int, input().split())
if n % m == 0:
	print(-1)
else:
	print(n * (m + 1))


XY = input().split()
(X, Y) = (int(XY[0]), int(XY[1]))
if X % Y != 0:
	print(X)
else:
	print(-1)


(x, y) = map(int, input().split())
if x % y == 0:
	print('-1')
else:
	for i in range(1, x * y):
		if x * i % y != 0:
			print(x * i)
			exit()


(X, Y) = map(int, input().split())
if X % Y == 0:
	print(-1)
elif Y == 2:
	print(X * 3)
else:
	print(X * (Y - 1))


num = input().split(' ')
num = [int(i) for i in num]
if num[0] % num[1] == 0:
	print('-1')
else:
	print(num[0])


(X, Y) = map(int, input().split())
if X % Y == 0 or X > 10 ** 18:
	print(-1)
else:
	print(X)


import math
import sys
(x, y) = map(int, input().split())
if x % y != 0:
	print(x)
else:
	print(-1)


b = []
b = input().strip().split()
b[0] = int(b[0])
b[1] = int(b[1])
if b[0] % b[1] == 0:
	print('-1')
else:
	print(b[0])


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


(a, b) = map(int, input().split())
print([a * b + a, -1][a % b == 0])


import sys
input = sys.stdin.readline
(x, y) = map(int, input().split())
if x % y == 0:
	ans = -1
else:
	ans = x
print(ans)


(X, Y) = map(int, input().split())
if X % Y == 0:
	print(-1)
	exit()
print(X)


(X, Y) = map(int, input().split())
a = X / Y
if a == int(a):
	ans = -1
else:
	ans = X
print(ans)


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


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


(X, Y) = map(int, input().split())
ans = X
if X % Y == 0:
	ans = -1
print(ans)


(X, Y) = list(map(int, input().split()))
N = X
if X % Y == 0:
	print(-1)
else:
	while N % Y == 0:
		N += X
	print(N)


(X, Y) = [int(_) for _ in input().split()]
if X % Y:
	print(X)
else:
	print(-1)


(X, Y) = [int(x) for x in input().split()]
if X % Y == 0:
	ans = -1
else:
	ans = X * (Y - 1)
print(ans)
print()


import sys
(x, y) = map(int, input().split())
k = 0
if x % y == 0 or x * (y - 1) > 10 ** 18:
	print(-1)
else:
	print(x * (y - 1))


a = input().split(' ')
X = int(a[0])
Y = int(a[1])
if X % Y == 0:
	print(-1)
else:
	print(X)


import math
(x, y) = map(int, input().split())
xy = x * y // math.gcd(x, y)
if xy > x:
	print(x)
else:
	print(-1)


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


import sys
(X, Y) = map(int, input().split())
if X % Y == 0:
	print(-1)
	sys.exit()
print(X)


from math import gcd
(X, Y) = map(int, input().split())
l = X * Y // gcd(X, Y)
if l == X:
	print(-1)
else:
	print(X)


(x, y) = map(int, input().split())
print(-(x % y == 0) or x)


(X, Y) = map(int, input().split())
print(X * ~-Y * (X % Y > 0) or -1)


def resolve():
	(X, Y) = map(int, input().split())
	print('-1' if X % Y == 0 else X * (Y - 1))
resolve()


(x, y) = map(int, input().split())
if x % y == 0:
	exit(print(-1))
t = 0
for i in range(1000001):
	t += x
	if t % y != 0:
		print(t)
		exit(0)


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


(a, b) = map(int, input().split())
m = a % b
if m == 0 or b == 1:
	print(-1)
else:
	print(a * (b + 1))


(X, Y) = map(int, input().split())
for i in range(2, 10 ** 5):
	if i * X % Y != 0:
		print(i * X)
		break
else:
	print(-1)


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


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


(X, Y) = map(int, input().split())
X0 = X
res = -1
if X % Y != 0:
	while True:
		if X % Y != 0:
			res = X
			break
		X *= X0
print(res)


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


(X, Y) = map(int, input().split())
i = X + X
MAX = 10 ** 18
if X % Y == 0:
	print(-1)
else:
	print(X)


from math import gcd
(X, Y) = [int(i) for i in input().split()]
lcm = X * Y // gcd(X, Y)
if lcm == X:
	print(-1)
else:
	print(X)


from fractions import gcd
(x, y) = map(int, input().split())
if gcd(x, y) == y:
	print(-1)
else:
	print((y - 1) * x)


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


(x, y) = map(int, input().split())
for i in range(10 ** 5):
	if x * i % y != 0:
		print(x * i)
		exit()
print(-1)


def resolve():
	(X, Y) = [int(i) for i in input().split()]
	if X % Y == 0:
		print(-1)
	else:
		print(X)
resolve()


import math
(X, Y) = map(int, input().split())
a = X * Y // math.gcd(X, Y) - X
if a == 0:
	print(-1)
	exit()
print(a)


(x, y) = map(int, input().split())
if x == y:
	print(-1)
elif (x / y).is_integer():
	print(-1)
else:
	print(x)


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


(X, Y) = list(map(int, input().split()))
if X % Y == 0:
	ans = -1
else:
	ans = X
print(ans)


(x, y) = map(int, input().split())
print(-(x % y < 1) or x)


(X, Y) = [int(n) for n in input().split(sep=' ')]
print(X if X % Y != 0 else -1)


(a, c) = map(int, input().split())
print((1 + a) * (a % c > 0) - 1)


import sys
(a, b) = map(int, input().split())
if a % b == 0:
	print(-1)
else:
	print(a)


(x, y) = map(int, input().split())
for c in range(2, 1000000):
	if c * x % y != 0:
		print(c * x)
		break
else:
	print(-1)


line = input().split(' ')
x = int(line[0])
y = int(line[1])
if x % y == 0:
	print('-1')
else:
	print(x)


(X, Y) = map(int, input().split())
for i in range(1, 10 ** 6):
	if X * i % Y != 0:
		print(X * i)
		exit()
print(-1)


def main():
	(X, Y) = map(int, input().split())
	if not X % Y:
		print(-1)
	else:
		print(X)
main()


(x, y) = map(int, input().split())
for i in range(100):
	if x * i % y != 0:
		print(x * i)
		break
else:
	print(-1)


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


(x, y) = [int(x) for x in input().split()]
ans = x
if ans % y == 0:
	ans += y
print(-1 if ans % y == 0 or ans > 1e+18 else ans)


import fractions as math
(X, Y) = [int(x) for x in input().split()]
lcm = X * Y // math.gcd(X, Y)
if lcm == X:
	print(-1)
else:
	print(X)


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


from fractions import gcd
(X, Y) = map(int, input().split())
if gcd(X, Y) == Y:
	print(-1)
else:
	print(X)


def abc():
	(x, y) = map(int, input().rstrip().split())
	if x % y == 0:
		print(-1)
		return
	print(x)
abc()


(X, Y) = list(map(int, input().split()))
if X % Y == 0:
	re = -1
elif X < Y:
	re = X
else:
	re = X * Y - X
print(re)


(X, Y) = map(int, input().split())
i = 1
while X < 1000000001:
	X *= i
	if X % Y != 0:
		print(X)
		break
	i += 1
else:
	print(-1)