SPOJ Problem Set (partial)
2830. Integers
Problem code: INTEGER7

Find two nonnegative integers x1 and x2 so that a_{1} * x_{1} + b_{1} = a_{2} * x_{2} + b_{2} and x_{1} + x_{2} is minimized. Given that there exist x_{1} and x_{2} satisfying the above equation.
Input
 A single line containing four integers a_{1}, b_{1}, a_{2}, b_{2} (the integers are within the interval [0..2^{31}1].
Output
 Print two integers x_{1}, x_{2}.
Example
Input
3 4 5 5
Output
2 1
