#include using namespace std; #define modulo 1000000007 #define mod(mod_x) ((((long long)mod_x+modulo))%modulo) #define Inf 1000000009 int main(){ int T; cin>>T; for(int i=0;i>A>>B>>C; if(A>B&&C>B){ if(A==C){ if(B+1==A){ if(B==1)cout<<-1<C)swap(A,C); int ans = 0; int x = 0; if(A==B){ ans++; x++; if(A==C){ ans+=2; x++; } if(B-x<=0)ans = -1; } else if(B==C){ ans++; x++; if(C-1==A){ ans++; x++; } if(C-x<=0)ans = -1; } else{ ans = Inf; if(A!=1)ans = min(ans,B-A+1); if(B-A!=1)ans = min(ans,C-B+1); if(ans==Inf)ans = -1; } cout<