atcoder#ABC296D. [ABC296D] M<=ab

[ABC296D] M<=ab

Score : 400400 points

Problem Statement

You are given positive integers NN and MM. Find the smallest positive integer XX that satisfies both of the conditions below, or print 1-1 if there is no such integer.

  • XX can be represented as the product of two integers aa and bb between 11 and NN, inclusive. Here, aa and bb may be the same.
  • XX is at least MM.

Constraints

  • 1N10121\leq N\leq 10^{12}
  • 1M10121\leq M\leq 10^{12}
  • NN and MM are integers.

Input

The input is given from Standard Input in the following format:

NN MM

Output

Print the smallest positive integer XX that satisfies both of the conditions, or 1-1 if there is no such integer.

5 7
8

First, 77 cannot be represented as the product of two integers between 11 and 55. Second, 88 can be represented as the product of two integers between 11 and 55, such as 8=2×48=2\times 4.

Thus, you should print 88.

2 5
-1

Since 1×1=11\times 1=1, 1×2=21\times 2=2, 2×1=22\times 1=2, and 2×2=42\times 2=4, only 11, 22, and 44 can be represented as the product of two integers between 11 and 22, so no number greater than or equal to 55 can be represented as the product of two such integers. Thus, you should print 1-1.

100000 10000000000
10000000000

For a=b=100000a=b=100000 (=105)(=10^5), the product of aa and bb is 1000000000010000000000 (=1010)(=10^{10}), which is the answer. Note that the answer may not fit into a 3232-bit integer type.