Given three integers , let’s consider the representation of in base . Since ,
resulting in
, the representation will be: .
Sometimes the representation can be finite, sometimes it is not. If infinite, sometimes it repeats, and sometimes it does not. When it repeats, sometimes it starts repeating from a certain position, not at the beginning, or sometimes at the beginning.
In this problem, for any given , you need to find the type of representation, and if it repeats then the length of the representation along with the starting position of the repetition.
The first line contains an integer denoting the number of test cases.
Each of the next lines contains three space-separated integers , , and . All test cases are randomly generated, and all input numbers are in base 10.
For each case, if the representation is finite then print "finite" without quotes and the length of the representation separated by space.
If the representation is infinite, then if there is no repetition then print "infinite " without quotes. If there is repetition, then print "infinite " without quotes where is the length of the representation string before repetition and is the length of repetition.
Input | Output |
---|---|
3 1 2 10 1 3 10 1 6 10 | finite 1 infinite 0 1 infinite 1 1 |
This numerical representation of fractions is not well-defined. That is two different numerical representations can represent the same number. For example, and represent the same number. In such cases, use the finite representation. Another more concrete example is for the first sample input “1 2 10”, 1/2 = 0.5 in base 10 or one could say, 1/2 = 0.4999999…. In such cases consider 1/2=0.5 which is the finite numerical representation of 1/2 in base 10.