#include <bits/stdc++.h>
using namespace std;
signed main(void) {
  int a[4], t;
  cin >> t;
  while (t--) {
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    int k = ((a[0] + a[1]) / 2 + a[2]) / 2;
    for (int i = 0; i < 3; ++i) a[i] += a[i] < k ? 1 : (a[i] > k ? -1 : 0);
    cout << abs(a[0] - a[1]) + abs(a[0] - a[2]) + abs(a[1] - a[2]) << endl;
  }
}
