cho.sh
Notes
Loading...

Fraction Sum

Time limit

2s

Memory limit

128 MB

Problem

Given two fractions A/B and C/D whose numerators and denominators are natural numbers, compute their sum and write it as a reduced fraction. A reduced fraction is one whose numerator and denominator have greatest common divisor 1.

Input

The first line contains the numerator and denominator A B of the first fraction. The second line contains the numerator and denominator C D of the second fraction. All four numbers are natural numbers no greater than 30,000.

Output

Print the numerator and denominator of the reduced sum, separated by one space.