# Five for week 16 (2013-2014)

# Exact Number of Drops

- Hmm... I asked for 400 drops, but there are 402 here.

- 400 drops, we never make mistakes.

Russian cartoon _The Mystery of the Third Planet

Do you think that managing a restaurant is easy? That is not the case when all clients are pretty demanding.

You are managing a restaurant, and every day a lot of people come and ask you to give them some drinks. As your restaurant has just recently opened, you don't have any vessels except two, which can accommodate a drops of liquid and b drops of liquid, respectively. In order not to make your clients wait (or at least to minimize their waiting time), you always have to determine the minimal number of steps required to obtain exactly c drops of liquid in one of the vessels.

At the beginning both vessels are empty. The following operations are counted as steps:

emptying a vessel;

filling a vessel;

pouring liquid from one vessel to the other (without spilling) until one of the vessels is either full or empty.

Eventually you became tired to do it all by hand and decided to write a program which will help you calculate the minimum number of steps required in all these cases.

## Input data

The first line contains the number of test cases T (1 ≤ T ≤ 105). Each of the next T lines contains one testcase and consists of three integers a, b and c (1 ≤ a, b, c ≤ 109).

Output

For each test case print the minimum number of steps required to obtain exactly c drops of liquid in one of the vessels or -1 if this is impossible.

## Examples

2 2 5 4 5 3 7

4 -1