#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  cin >> t;
  while (t--) {
    int i, a[3], ans, m;
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    m = (a[0] + a[2]) / 2;
    if (a[0] < m) a[0]++;
    if (a[1] < m) a[1]++;
    if (a[1] > m) a[1]--;
    if (a[2] > m) a[2]--;
    ans = abs(a[0] - a[1]) + abs(a[0] - a[2]) + abs(a[1] - a[2]);
    cout << ans << endl;
  }
  return 0;
}
