#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a c if(b==2) return INF; Int res=0; if(a>=b) res+=a-b+1,a=b-1; if(c>=b) res+=c-b+1,c=b-1; if(a==c) res++; return res; } Int p2(Int a,Int b,Int c){ Int res=0; if(a==c) a--,res++; if(min(a,c)<=1) return INF; res+=b-min(a,c)+1; return res; } signed solve(){ Int a,b,c; cin>>a>>b>>c; Int ans=min(p1(a,b,c),p2(a,b,c)); if(ans==INF) ans=-1; cout<>T; while(T--) solve(); return 0; }