Time limit
2s
Memory limit
128 MB
Computers handle integers as their basic numeric representation, so representing real numbers requires additional methods. Floating-point representation is widely used because it is fast and convenient, but it can introduce errors.
Suppose a program represents real numbers as reduced fractions. Given one reduced fraction, find a different reduced fraction whose value is closest to it.
The distance between two fractions is the absolute difference between the real values they represent. If several reduced fractions have the minimum distance, choose the fraction with the smallest value.
For this problem, every numerator and denominator is between 1 and 32767, inclusive. A reduced fraction is a fraction whose numerator and denominator have greatest common divisor 1.
The first line contains the numerator and denominator of the given fraction, separated by a space. The numerator is smaller than the denominator, and the given fraction is reduced.
Print the numerator and denominator of the different reduced fraction closest to the given fraction, separated by a space.