#include <iostream>
#include <algorithm>
using namespace std;
int gcd(int a, int b) {
while (b != 0) {
int temp = b;
b = a % b;
a = temp;
}
return a;
}
int gcd(int a, int b, int c) {
return gcd(gcd(a, b), c);
}
int min_operations(int A, int B, int C) {
int G = gcd(A, B, C);
int max_value = max(A, max(B, C));
int min_value = min(A, min(B, C));
int delta = max_value - min_value;
return delta / G;
}
int main() {
int t;
cin >> t;
while (t--) {
int A, B, C;
cin >> A >> B >> C;
int result = min_operations(A, B, C);
cout << result << endl;
}
return 0;
}