#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
while (y != 0) {
int t = y;
y = x % y;
x = t;
}
return x;
}
void solution() {
int A, B, C;
cin >> A >> B >> C;
int arr[3] = {A, B, C};
sort(arr, arr + 3); // Sort the array to easily find the minimum, middle, and maximum values
if (arr[0] == arr[1] && arr[1] == arr[2]) {
cout << 0 << "\n";
return;
}
if (arr[0] == arr[1] || arr[1] == arr[2]) {
cout << 1 << "\n";
return;
}
// Compute the GCD of the differences
int diff1 = arr[2] - arr[0];
int diff2 = arr[2] - arr[1];
int diff3 = arr[1] - arr[0];
int common_gcd = gcd(gcd(diff1, diff2), diff3);
if (common_gcd == 1) {
// If GCD is 1, at least two operations are needed
cout << 2 << "\n";
} else {
// Otherwise, it can be done in 1 operation
cout << 1 << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while (T--) {
solution();
}
return 0;
}