#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int t; cin >> t;
while(t--){
int a, b, c; cin >> a >> b >> c;
vector<int> vect = {a, b, c};
sort(vect.begin(), vect.end());
int diff1 = vect[1] - vect[0];
int diff2 = vect[2] - vect[1];
if (diff1 == 0 && diff2 == 0) {
cout << 0 << '\n';
continue;
}
int k = __gcd(diff1, diff2);
if (k == 0) {
cout << -1 << '\n';
continue;
}
int cnt = (diff1 / k) + (diff2 / k);
cout << cnt << '\n';
}
return 0;
}