#include <bits/stdc++.h>
using namespace std;
void solve()
{
int x[3];
cin >> x[0] >> x[1] >> x[2];
int avg = ceil((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]++;
}
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+IHhbMl07CgogICAgaW50IGF2ZyA9IGNlaWwoKHhbMF0gKyB4WzFdICsgeFsyXSkgLyAzKTsKCiAgICBmb3IgKGludCBpID0gMDsgaSA8IDM7IGkrKykKICAgIHsKICAgICAgICBpZiAoeFtpXSA+IGF2ZykKICAgICAgICAgICAgeFtpXS0tOwogICAgICAgIGVsc2UgaWYgKHhbaV0gPCBhdmcpCiAgICAgICAgICAgIHhbaV0rKzsKICAgIH0KCgogICAgaW50IGFucyA9IGFicyh4WzBdIC0geFsxXSkgKyBhYnMoeFswXSAtIHhbMl0pICsgYWJzKHhbMV0gLSB4WzJdKTsKICAgIAogICAgY291dCA8PCBhbnMgPDwgIlxuIjsKfQoKaW50IG1haW4oKQp7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgIGNpbi50aWUoMCk7CgogICAgaW50IHQ7CiAgICBjaW4gPj4gdDsKCiAgICB3aGlsZSAodC0tKQogICAgewogICAgICAgIHNvbHZlKCk7CiAgICB9Cn0=
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