#include using namespace std; typedef unsigned long long int ull; typedef long long int ll; typedef pair pll; typedef long double D; //typedef complex P; #define F first #define S second const ll MOD=1000000007; //const ll MOD=998244353; templateistream & operator >> (istream &i,pair &A){i>>A.F>>A.S; return i;} templateistream & operator >> (istream &i,vector &A){for(auto &I:A){i>>I;} return i;} templateostream & operator << (ostream &o,const pair &A){o<ostream & operator << (ostream &o,const vector &A){int i=A.size(); for(auto &I:A){o<C){swap(A,C);} if(A==C){A--; ret++;} if(B==C){C--; ret++; if(A==C){A--; ret++;}} else if(AC-B+1+(A==B-1?1:0)){ ret+=C-B+1; C=B-1; if(A==C){A--; ret++;} } else{ret+=B-A+1; B=A-1;} } else if(A==B){B--; ret++;} if(A<1 || B<1 || C<1){ret=-1;} return ret; } int main(){ cin.tie(0); ios::sync_with_stdio(false); ll T; cin>>T; for(int i=0;i>a>>b>>c; cout<