All Tracks Math Number Theory Problem

Prime Numbers
Tag(s):

Easy-Medium, Math, Shortest-path

Problem
Editorial
Analytics

The author of this problem hopes that you still have not forgotten about the pig called Benny :)

Recently, she started learning numbers. The first type of numbers she has learnt is "Prime" numbers. The number is called prime if it has only 2 divisors including 1 and itself.

As a homework Benny was given two integers A and B. She has to transform A into B using addition and subtraction.

Here is only one restriction: since Benny knows only prime numbers she might add and subtract only prime numbers. Moreover, all the partial results also have to be prime numbers.

Your task is no find the way how Benny can transform number A into B with minimal number of additions and subtractions. If there are multiple ways - output "Poor Benny". If there is no way to transform A into B output "Unlucky Benny". Otherwise output the transformation with all partial results i.e you have to output A then -> then number in transformation then -> again and so on. The last number has to be equal to B. In other words A, B and any other temporary values during transformations should be separated by ->.

Input

The input data consists of only one single line containing two integers denoting A and B respectively.

Output

In a single line output the answer to the problem.

Constraints

  • 2A < B1015

It's guaranteed that A and B are prime numbers.

SAMPLE INPUT
5 7
SAMPLE OUTPUT
5->7
Explanation

In this test case Benny just has to add 2 to A and she will receive the expected result.

Time Limit: 2.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

HackerEarth Collegiate Cup Wildcard

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications