Hide

Problem F
Brahmagupta-Fibonacci

Languages en is

You are given non-negative integers $a, b, c, d$. Let $p = a^2 + b^2$ and $q = c^2 + d^2$. You are to use these two formulas to find two ways to write $pq$ as a sum of two squares.

Input

The first and only line of input contains non-negative integers $a, b, c, d \leq 10^{18}$ separated by a space.

Output

Print two lines of the form x^2 + y^2 = pq where $x, y$ are integers and $pq$ is the product of $p, q$. If $x$ or $y$ are negative they need to be wrapped in parentheses, like in the sample input.

Sample Input 1 Sample Output 1
10 5 7 8
30^2 + 115^2 = 14125
110^2 + 45^2 = 14125
Sample Input 2 Sample Output 2
12 13 10 11
(-23)^2 + 262^2 = 69173
263^2 + 2^2 = 69173

Please log in to submit a solution to this problem

Log in