Chocolate
Anna and Beka are dividing a rectangular chocolate bar of size M×N. They take turns breaking off a square piece from one end of the chocolate bar, with the side length equal to the shorter side of the bar. If at any point the remaining chocolate is square-shaped, the child whose turn it is takes the entire remaining piece, and the division ends. Anna goes first.
Consider an example: the chocolate bar is initially 6×10. Anna breaks off a 6×6 piece. Beka then takes a 4×4 piece from the remaining 6×4 chocolate. Anna next takes a 2×2 piece from the remaining 2×4, and Beka takes the final 2×2 piece. Thus, Anna receives pieces with a total area of 40, and Beka receives pieces with a total area of 20.
Given the total area of chocolate each child received, determine the initial dimensions M and N of the chocolate bar such that the areas received by the children match the given values.
If there are multiple solutions, choose the one where M is smallest. If there are still multiple solutions, choose the one where N is smallest. If no such M and N exist, output -1.
Input
The first line contains two integers: the area of chocolate received by Anna and the area received by Beka. The combined area of chocolate pieces received by Anna and Beka is at least 1 and does not exceed 1000000000.
Output
If a solution exists, output the pair of numbers M and N, separated by a space. Otherwise, output -1.