403361: GYM101138 I Prime Moving
Description
The author of this problem hopes that you already know the pig called Benny.
Recently she started learning numbers. The first type of numbers she has learnt are primes, i.e. positive integers with exactly two divisors. First few primes are 2, 3, 5, 7 and 11.
As a homework Benny was given two primes a and b. She has to transform a into b using addition and subtraction.
Since Benny knows only primes, she might add and subtract only primes. Moreover, all the partial results also have to be primes.
One move is either adding or subtracting a prime to/from the current number. A way of transforming a into b is called optimal if it doesn't use more moves than any other way. Your task is to find the only optimal way, if exactly one exists.
If it's impossible to transform a into b, print "Unlucky Benny" (without the quotes). If there are multiple optimal ways, print "Poor Benny" (without the quotes). Otherwise output the transformation with all partial results. See the output format below.
InputThe only line of the input contains two integers a and b (2 ≤ a < b ≤ 1015). Both a and b are primes.
OutputIf the transformation is impossible, print "Unlucky Benny".
If there are many optimal ways, print "Poor Benny".
If there is exactly one optimal way to transform a into b, describe the process in the following format. Let x1, x2, ..., xk denote values of Benny's number in the order. So x1 = a, xk = b and Benny changes xi to xi + 1 in the i-th move. In a single line print k numbers separated with two characters "->", without the quotes and spaces.
ExampleInput5 7Output
5->7Note
One move is enough in the sample.
If the only optimal way was to change 5 to 20, then change 20 to 10, and then finally change 10 to 7, the output would be 5->20->10->7. Though, such a way is not only non-optimal but also it isn't valid. In the first move (from 5 to 20) we try to add 15 what is not prime. Also, a new number 20 isn't prime. This note is only to show you the correct format.