#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void Solve()
{
ll a,b,c;
cin >> a>>b>>c;
ll ans = INT_MAX;
ll d = __gcd(a,b);
ll e = __gcd(d,c);
ll ans1=0, ans2=0, ans3=0;
ans1 = (abs(a-b)/e)+abs(a-c)/e;
ans2 = (abs(b-a)/e)+abs(b-c)/e;
ans3 = (abs(c-a)/e)+abs(c-b)/e;
if (a==b or b==c or c==a){
ans = 1;
}
cout<<min(ans,(ans1, min(ans2,ans3)))<<endl;
}
int32_t main()
{
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t = 1;
cin >> t;
while (t--)
Solve();
return 0;
}