For her new ICS assignment, Caroline needs to design a program that uses random numbers. However, she discovers that Ms. Dyke has forbidden using any built-in functions! Now, she needs to create a random number generator to make her assignment work. After checking online, she finds that random numbers can be generated using the following function:

Where is some initial value between and inclusive. After some tinkering she finds that for most values of , , and , the generated numbers quickly fall into a repeating cycle. She'd like to figure out which values of , , and produce the best results and has enlisted your help to find the average length of a cycle for one set of values.

**Note**: The cycle length for some value of is defined as smallest value for which
produces a number already in the sequence. For example, if and , then the cycle length is , as was already in the sequence. The average length of a cycle is defined as the average of the cycle lengths for every
possible value of .

#### Input Specification

The first line of the input provides the number of test cases, . test cases follow. Each test case contains 3 integers, , and .

For the first of cases, .

#### Output Specification

For each test case, your program should output one real number, rounded to 6 decimal places, the average length of a cycle.

#### Sample Input

```
2
3 2 5
4 5 3
```

#### Sample Output

```
3.400000
3.000000
```

#### Explanation for Sample

In the second test case, if you start with a of , then

Since is already in the sequence, the cycle length is . Starting with or will also result in a cycle length of , so the average cycle length is .

## Comments