#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 7;
const long double EPS = 0;
const long long MOD = (long long)pow(2, 32);
void input() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
void end() {}
int main() {
  input();
  int t;
  cin >> t;
  for (int o = 0; o < t; o++) {
    int x1, x2, x3;
    cin >> x1 >> x2 >> x3;
    if (x2 < x1) swap(x2, x1);
    if (x3 < x1) swap(x3, x1);
    if (x3 < x2) swap(x2, x3);
    cout << max(2 * (x3 - x1 - 2), 0) << endl;
  }
  end();
  return 0;
}
