#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fast ios::sync_with_stdio(false);cin.tie(nullptr)
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
return a / gcd(a, b) * b;
}
string toupper(string a) {
for (int i = 0; i < (int)a.size(); ++i)
if (a[i] >= 'a' && a[i] <= 'z')
a[i] -= 32;
return a;
}
string tolower(string a) {
for (int i = 0; i < (int)a.size(); ++i)
if (a[i] >= 'A' && a[i] <= 'Z')
a[i] += 32;
return a;
}
bool prime(ll a) {
if (a == 1)
return false;
for (int i = 2; i <= round(sqrt(a)); ++i)
if (a % i == 0)
return false;
return true;
}
constexpr long long pow(long long a, long long b) {
long long res = 1;
for (; b; b /= 2, a *= a) {
if (b % 2)
res *= a;
}
return res;
}
constexpr int factorial(int k) {
int res = 1;
for (int i = 2; i <= k; i++)
res *= i;
return res;
}
bool check() {
return true;
}
bool cmp(pair<int, int> a, pair<int, int> b) {
if (a.first == b.first) return (a.second > b.second);
return (a.first < b.first);
}
bool check(int a, int b, int c) {
if ( a== b && b == c && a == c) {
return true;
}
else return false;
}
int main () {
fast;
int tc;
cin >> tc;
while (tc--) {
vector <int> v(3);
for (int i=0; i<3; i++) {
cin >> v[i];
}
sort (v.begin(), v.end());
if (v[0] == v[1] && v[1] == v[2]) {
cout << 0 << endl;
}
else if (v[0] == v[1] || v[1] == v[2] || v[0] == v[2]) {
cout << 1 << endl;
}
else {
int val1 = abs(v[0] - v[1]);
int val2 = abs(v[1] - v[2]);
int mini = min(val1, val2);
if (mini == val1) {
if (val2%mini == 0) {
cout << 1 + val2/val1 << endl;
}
else {
cout << val1 + val2 << endl;
}
}
else if (mini == val2) {
if (val1%mini == 0) {
cout << 1 + val1/val2 << endl;
}
else {
cout << val1 + val2 << endl;
}
}
}
}
return 0;
}