#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t; cin >> t;
while(t--) {
int arr[3];
for (int i = 0; i < 3; i++) {
cin >> arr[i];
}
int diff[3];
diff[0] = abs(arr[0] - arr[1]);
diff[1] = abs(arr[1] - arr[2]);
diff[2] = abs(arr[2] - arr[0]);
int gcdd = 0;
for (int i = 0; i < 3;i++) {
gcdd = __gcd(gcdd,diff[i]);
}
sort(arr+0,arr+3);
ll ans = 0;
ans += (arr[1] - arr[0]) / gcdd;
ans += (arr[2] - arr[1]) / gcdd;
cout << ans << endl;
}
return 0;
}