Олимпиадный тренинг

Задача 38754. financial reform


Задача

Темы:
One day, after the Olympiad in Economics, Misha had a very colorful and unusual dream.
The boy turned out to be the Minister of Finance of Berland. Realizing his importance, he immediately decided to reform the country. Previously, banknotes with denominations of 1, 10, 100 & nbsp; and 1,000 burles were used in Berland. Misha found this system to be extremely banal, so he decided to come up with something of his own.
The boy chose two integers x and y (x ≤ y) and stated that now only banknotes with denominations x, x + 1, x + 2, will be used in Berland. . . , y burles. Soon the reform was adopted and entered into force, but the population of the country did not like it at all. Dissatisfaction began due to the fact that now, using new banknotes, it was possible to collect far from any amount.
For example, if the numbers x = 5 and y = 7 were chosen by Misha, then it is impossible to score the sums 1, 2, & nbsp; 3 and 4 bourles. Also, it will not be possible to dial the amounts of 8 and 9 burles. If you choose the numbers x = y = 2, then it will be impossible to score any odd amount.
Misha, being on the verge of being fired, decided to reassure the population of Berland and present such a minimum number N that with the help of new banknotes it is possible to collect any amount, starting with N. Thus, it should be possible to collect the sums of N burles, N + 1 burles, N + 2 burles, and so on. Help Misha find the desired number N and avoid being fired.

Input
The first line of the input contains an integer x — minimum denomination of new banknotes.
The second line contains an integer y (1 ≤ x ≤ y ≤ 2 · 109 ) — maximum denomination of new banknotes.

Imprint
Print one natural number N — the minimum number such that using banknotes with denominations x, x + 1, x + 2, . . . , y, you can collect any amount, starting with N burles. If such a number does not exist, print −1 as an answer.

 
Examples
# Input Output Explanation
1 5
7
10 There are banknotes of three denominations: 5, 6 and 7 bourles. Below are the amounts
which can be typed using these banknotes:
x 5 = 5
x 6 = 6,
x 7 = 7,
x 10 = 5 + 5
x 11 = 5 + 6,
x 12 = 5 + 7 x 13 = 6 + 7,
x . . .
It can be shown that with the help of banknotes of these denominations it is possible to collect any amount, starting from 10 bourles.
2 2
2
-1 There are banknotes of only one denomination: 2 bourles. Using these banknotes, you can only dial any even amount: 2, 4, 6, .... Thus, the required number N does not exist.
3 1900000000
2000000000
36100000000