#P1272A. Three Friends

    ID: 1948 Type: RemoteJudge 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>brute forcegreedymathsortings*900

Three Friends

No submission language available for this problem.

Description

Three friends are going to meet each other. Initially, the first friend stays at the position x=ax = a, the second friend stays at the position x=bx = b and the third friend stays at the position x=cx = c on the coordinate axis OxOx.

In one minute each friend independently from other friends can change the position xx by 11 to the left or by 11 to the right (i.e. set x:=x1x := x - 1 or x:=x+1x := x + 1) or even don't change it.

Let's introduce the total pairwise distance — the sum of distances between each pair of friends. Let aa', bb' and cc' be the final positions of the first, the second and the third friend, correspondingly. Then the total pairwise distance is ab+ac+bc|a' - b'| + |a' - c'| + |b' - c'|, where x|x| is the absolute value of xx.

Friends are interested in the minimum total pairwise distance they can reach if they will move optimally. Each friend will move no more than once. So, more formally, they want to know the minimum total pairwise distance they can reach after one minute.

You have to answer qq independent test cases.

The first line of the input contains one integer qq (1q10001 \le q \le 1000) — the number of test cases.

The next qq lines describe test cases. The ii-th test case is given as three integers a,ba, b and cc (1a,b,c1091 \le a, b, c \le 10^9) — initial positions of the first, second and third friend correspondingly. The positions of friends can be equal.

For each test case print the answer on it — the minimum total pairwise distance (the minimum sum of distances between each pair of friends) if friends change their positions optimally. Each friend will move no more than once. So, more formally, you have to find the minimum total pairwise distance they can reach after one minute.

Input

The first line of the input contains one integer qq (1q10001 \le q \le 1000) — the number of test cases.

The next qq lines describe test cases. The ii-th test case is given as three integers a,ba, b and cc (1a,b,c1091 \le a, b, c \le 10^9) — initial positions of the first, second and third friend correspondingly. The positions of friends can be equal.

Output

For each test case print the answer on it — the minimum total pairwise distance (the minimum sum of distances between each pair of friends) if friends change their positions optimally. Each friend will move no more than once. So, more formally, you have to find the minimum total pairwise distance they can reach after one minute.

Samples

Sample Input 1

8
3 3 4
10 20 30
5 5 5
2 4 3
1 1000000000 1000000000
1 1000000000 999999999
3 2 5
3 2 6

Sample Output 1

0
36
0
0
1999999994
1999999994
2
4