CF1986A.X Axis

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

X Axis

You are given three points with integer coordinates x1x_1, x2x_2, and x3x_3 on the XX axis (1xi101 \leq x_i \leq 10). You can choose any point with an integer coordinate aa on the XX axis. Note that the point aa may coincide with x1x_1, x2x_2, or x3x_3. Let f(a)f(a) be the total distance from the given points to the point aa. Find the smallest value of f(a)f(a).

The distance between points aa and bb is equal to ab|a - b|. For example, the distance between points a=5a = 5 and b=2b = 2 is 33.

Input

Each test consists of multiple test cases. The first line contains a single integer tt (1t1031 \leq t \leq 10^3) — the number of test cases. Then follows their descriptions.

The single line of each test case contains three integers x1x_1, x2x_2, and x3x_3 (1xi101 \leq x_i \leq 10) — the coordinates of the points.

Output

For each test case, output the smallest value of f(a)f(a).

Note

In the first test case, the smallest value of f(a)f(a) is achieved when a=1a = 1: f(1)=11+11+11=0f(1) = |1 - 1| + |1 - 1| + |1 - 1| = 0.

In the second test case, the smallest value of f(a)f(a) is achieved when a=5a = 5: f(5)=15+55+95=8f(5) = |1 - 5| + |5 - 5| + |9 - 5| = 8.

In the third test case, the smallest value of f(a)f(a) is achieved when a=8a = 8: f(8)=88+28+88=6f(8) = |8 - 8| + |2 - 8| + |8 - 8| = 6.

In the fourth test case, the smallest value of f(a)f(a) is achieved when a=9a = 9: f(10)=109+99+39=7f(10) = |10 - 9| + |9 - 9| + |3 - 9| = 7.

Samples

8
1 1 1
1 5 9
8 2 8
10 9 3
2 1 1
2 4 1
7 3 5
1 9 4
0
8
6
7
1
3
4
8

在线编程 IDE

建议全屏模式获得最佳体验