#include <bits/stdc++.h>
using namespace std;
void solve()
{
int x[3];
cin >> x[0] >> x[1] >> x[2];
double avg_d = (x[0] + x[1] + x[2]) / 3;
int avg = ceil(avg_d);
cout << "avg = "<<avg<<endl;
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"<<endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
solve();
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp2b2lkIHNvbHZlKCkKewogICAgaW50IHhbM107CiAgICBjaW4gPj4geFswXSA+PiB4WzFdID4+IHhbMl07CgogICAgCiAgICBkb3VibGUgYXZnX2QgPSAoeFswXSArIHhbMV0gKyB4WzJdKSAvIDM7CiAgICAKICAgIGludCBhdmcgPSBjZWlsKGF2Z19kKTsKICAgIAogICAgY291dCA8PCAiYXZnID0gIjw8YXZnPDxlbmRsOwoKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgMzsgaSsrKQogICAgewogICAgICAgIGlmICh4W2ldID4gYXZnKQogICAgICAgICAgICB4W2ldLS07CiAgICAgICAgZWxzZSBpZiAoeFtpXSA8IGF2ZykKICAgICAgICAgICAgeFtpXSsrOwogICAgfQoKICAgIGludCBhbnMgPSBhYnMoeFswXSAtIHhbMV0pICsgYWJzKHhbMF0gLSB4WzJdKSArIGFicyh4WzFdIC0geFsyXSk7CgogICAgY291dCA8PCBhbnMgPDwgIlxuIjw8ZW5kbDsKfQoKaW50IG1haW4oKQp7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgIGNpbi50aWUoMCk7CgogICAgaW50IHQ7CiAgICBjaW4gPj4gdDsKCiAgICB3aGlsZSAodC0tKQogICAgewogICAgICAgIHNvbHZlKCk7CiAgICB9Cn0=
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