#include #define rep(i,n) for(int i = 0; i < n; i++) #define mrep(i,j,n) for(int i = j; i < n; i++) #define reps(i,n) for(int i = 1; i <= n; i++) #define rrep(i,n) for(int i = n-1; i >= 0; i--) #define rreps(i,n) for(int i = n; i >= 1; i--) #define co(x) cout << x < #define vvi vector> #define vpii vector> #define vl vector #define vvl vector> #define vb vector #define vvb vector> #define vs vector typedef long long ll; typedef unsigned long long ull; using namespace std; ll mod = 1e9 + 7; templateinline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; } templateinline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; } bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; } int main() { int t; cin >> t; vvi a(t, vi(3, 0)); vi ans(t); rep(i, t)rep(j, 3)cin >> a[i][j]; rep(i, t) { int tmp = 0; int sum = 0; rep(j, 3)sum += a[i][j]; int mi = min(a[i][0], min(a[i][1], a[i][2])); int ma = max(a[i][0], max(a[i][1], a[i][2])); int mid = sum - mi - ma; if (mi == ma)tmp = mi > 2 ? 3 : -1; else if ((a[i][2] - a[i][1]) * (a[i][1] - a[i][0]) > 0) { if (mi > 1)tmp = mid - mi > 1 ? min(mid - mi + 1, ma - mid + 1) : 2; else tmp = mid - mi > 1 ? ma - mid + 1 : -1; } else if (mi == mid) { tmp = mi > 1 ? 1 : -1; } else if (ma == mid) { tmp = 1; } ans[i] = tmp; } rep(i, t)co(ans[i]); return 0; }