#include <bits/stdc++.h>
using namespace std;
void solve()
{
int x[3];
cin >> x[0] >> x[1] >> x[2];
// int avg = (x[0] + x[1] + x[2]) / 3;
// for (int i = 0; i < 3; i++)
// {
// if (x[i] > avg)
// x[i]--;
// else if (x[i] < avg)
// x[i]++;
// }
sort(x, x + 3);
if (x[0] < x[1])
x[0]++;
if (x[2] > x[1])
x[2]--;
int ans = abs(x[0] - x[1]) + abs(x[0] - x[2]) + abs(x[1] - x[2]);
cout << ans << "\n";
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
solve();
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp2b2lkIHNvbHZlKCkKewogICAgaW50IHhbM107CiAgICBjaW4gPj4geFswXSA+PiB4WzFdID4+IHhbMl07CgogICAgLy8gaW50IGF2ZyA9ICh4WzBdICsgeFsxXSArIHhbMl0pIC8gMzsKCiAgICAvLyBmb3IgKGludCBpID0gMDsgaSA8IDM7IGkrKykKICAgIC8vIHsKICAgIC8vICAgICBpZiAoeFtpXSA+IGF2ZykKICAgIC8vICAgICAgICAgeFtpXS0tOwogICAgLy8gICAgIGVsc2UgaWYgKHhbaV0gPCBhdmcpCiAgICAvLyAgICAgICAgIHhbaV0rKzsKICAgIC8vIH0KCiAgICBzb3J0KHgsIHggKyAzKTsKCiAgICBpZiAoeFswXSA8IHhbMV0pCiAgICAgICAgeFswXSsrOwogICAgaWYgKHhbMl0gPiB4WzFdKQogICAgICAgIHhbMl0tLTsKCiAgICBpbnQgYW5zID0gYWJzKHhbMF0gLSB4WzFdKSArIGFicyh4WzBdIC0geFsyXSkgKyBhYnMoeFsxXSAtIHhbMl0pOwoKICAgIGNvdXQgPDwgYW5zIDw8ICJcbiI7Cn0KCmludCBtYWluKCkKewogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7CiAgICBjaW4udGllKDApOwoKICAgIGludCB0OwogICAgY2luID4+IHQ7CgogICAgd2hpbGUgKHQtLSkKICAgIHsKICAgICAgICBzb2x2ZSgpOwogICAgfQp9
NTAKNTIgNDkgNDYKNDkgNDcgNTIKNTIgNDkgNDkKNDQgNDUgNTEKNDYgNDcgNDcKNDcgNDggNDYKNDkgNDQgNDYKNDMgNDQgNDMKNTIgNDkgNDUKNDYgNDggNDkKNDUgNTIgNTIKNTAgNTEgNDcKNDkgNTIgNTIKNDcgNDcgNDQKNDMgNDQgNDYKNDMgNTAgNTEKNDggNTEgNDYKNDcgNDYgNDMKNDYgNDcgNDUKNDMgNDkgNDYKNDggNDcgNTAKNDQgNDMgNDMKNDggNTEgNDcKNDMgNDQgNDcKNDMgNDYgNDYKNDkgNDQgNTIKNTEgNDUgNTAKNTEgNDcgNTEKNDYgNTEgNDYKNDkgNDYgNDQKNDkgNDQgNDcKNDggNTEgNDMKNDcgNTEgNTAKNTAgNTEgNDgKNTEgNTAgNTAKNTIgNTAgNDQKNTIgNDggNTIKNDMgNTAgNDQKNDggNDQgNTIKNTIgNDkgNTIKNTAgNDcgNDUKNDcgNDcgNTIKNDQgNDkgNDkKNTEgNDYgNDkKNTIgNTAgNTIKNDUgNDUgNDkKNDQgNTAgNDQKNTEgNDYgNTEKNDYgNDYgNDgKNDMgNDggNTE=
50
52 49 46
49 47 52
52 49 49
44 45 51
46 47 47
47 48 46
49 44 46
43 44 43
52 49 45
46 48 49
45 52 52
50 51 47
49 52 52
47 47 44
43 44 46
43 50 51
48 51 46
47 46 43
46 47 45
43 49 46
48 47 50
44 43 43
48 51 47
43 44 47
43 46 46
49 44 52
51 45 50
51 47 51
46 51 46
49 46 44
49 44 47
48 51 43
47 51 50
50 51 48
51 50 50
52 50 44
52 48 52
43 50 44
48 44 52
52 49 52
50 47 45
47 47 52
44 49 49
51 46 49
52 50 52
45 45 49
44 50 44
51 46 51
46 46 48
43 48 51