#CF1103C. Omsk Programmers 鄂木斯克程序员

Omsk Programmers 鄂木斯克程序员

当前没有测试数据。

CF测试跳转:https://codeforces.com/contest/2236/problem/C

An annual programmers fair is taking place on the main square of Omsk. You, as the main programmer of Omsk, decided to take part in this wonderful event and went there. At the entrance, a guard decided to check your skills and gave you a problem:

You are given three integers aa, bb, xx. You want to make aa and bb equal. In order to do so, you can apply the following operations:

  1. Choose one of the integers aa or bb and add 11 to it.
  2. Choose one of the integers aa or bb and divide it by xx with rounding down.

You need to find the minimum number of operations after which aa becomes equal to bb. Can you prove your skills, or will you have to go back home?

Input

The first line contains a single integer tt (1t104)(1 \le t \le 10^4) — the number of test cases.

Then tt test cases follow.

Each test case consists of a single line containing three integers aa, bb, xx (1a,b1091 \le a, b \le 10^9, 2x1092 \le x \le 10^9).

Output

For each test case, output a single integer — the minimum number of operations required to make aa and bb equal.

Samples

7
1 2 3
2 3 2
7 3 10
17 3 3
10 10 2
4 7 2
1 6 2
1
1
2
3
0
2
2