/*who_knows_*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T, typename R> using omap = tree<T, R, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int inf = 1e18 + 10;
const int N = 1e6 + 10;
void solve() {
vector<int>v(3);
cin >> v[0] >> v[1] >> v[2];
sort(all(v));
int d1 = v[1] - v[0], d2 = v[2] - v[1];
int g = __gcd(d1, d2);
if (g == 0) cout << 0 << endl;
else cout << d1 / g + d2 / g << endl;
}
int32_t main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int t = 1, cs = 1;
cin >> t;
while (t--) {
// cout << "Case " << cs++ << ": ";
solve();
}
return 0;
}