Wipe Your Whiteboards

Given R, S and Q, find positive integers A and B with A R + B S equal to Q, minimizing A first and then B.

Medium4Number theoryMathNo attempts yetTime limit5sMemory limit256 MB

Problem

You walk into an empty classroom to do some homework and find that someone did not clean the whiteboard properly. The previous class in that room was about the extended Euclidean algorithm, because the board is covered with intermediate results of that algorithm. Parts of it have been wiped out, so you do not see everything they did. In particular, you cannot tell which numbers they used as the inputs. You did not feel like doing your homework anyway, so you decide to work out the numbers they started with.

From the intermediate results left on the board you know one thing for certain. Their inputs were integers AA and BB (A,B1A, B \ge 1), and the three integers RR, SS and QQ still on the board (R2R \ge 2, S2S \le -2, Q1Q \ge 1) satisfy AR+BS=QA \cdot R + B \cdot S = Q. Given these three numbers, work out AA and BB. Several pairs can fit the equation, so look for the pair with the smallest positive AA and BB. You do not require RR, SS and QQ to be genuine intermediate results of the extended Euclidean algorithm applied to AA and BB. The equation AR+BS=QA \cdot R + B \cdot S = Q alone is enough.

Input

The first line contains an integer TT, the number of test cases.

Each test case is one line with three space-separated integers RR, SS and QQ. They satisfy 2R1082 \le R \le 10^8, 108S2-10^8 \le S \le -2 and 1Q1081 \le Q \le 10^8. QQ is a multiple of the greatest common divisor of RR and SS.

Output

For each test case, print one line with two space-separated integers A1A \ge 1 and B1B \ge 1, the smallest pair with AR+BS=QA \cdot R + B \cdot S = Q. The smallest pair is the one whose AA is minimal, and if several pairs share that AA, the one among them whose BB is minimal.