Rational Neighbor

As we know, finding a rational close to a given rational is straightforward. The minimal distance between two distinct integers is 1. By contrast, there is no minimal distance between two distinct rationals. A straightforward method for finding a rational close to a given rational a/b is based on the following construction. For every m > 0 one has a/b = (am)/(bm), and the neighbors (am ± 1)/(bm) lie at distance 1/(bm) from the given rational. So, by choosing m to be sufficiently large, one can make the distance to be as small as we please. Given a rational a/b and an upper bound n for the distance, the problem consists to find the rational c/d such that: (i) a/b < c/d; (ii) the distance between the rationals a/b and c/d is smaller or equal than n; (iii) the denominator d is as small as possible. Input The input will contain several test cases, each of them consisting of two lines. The first line of the input contains two positive integers a and b which define the rational number a/b. The integers a and b are assumed to be in the interval [1,100000]. The second line contain a positive real number n, 0.00000001 ≤ n ≤ 0.1, which gives the maximum distance allowed. Output For each test case, write to the output, on a line by itself, the two positive integers c and d which solve the problem. Sample Input 96 145 0.0001 Sample Output 49 74