#include using namespace std; int main(){ int t; cin >> t; for(int i=0;i> a >> b >> c; if(a<=0 || b<=0 || c<=0){ cout << -1 << endl; continue; } if((b>a && b>c && a!=c) || (b=3){ cout << 3 << endl; continue; } else{ cout << -1 << endl; continue; } } int p=max(a,c); int q=min(a,c); if(b==q+1){ if(q==1){ cout << -1 << endl; continue; } else{ cout << 2 << endl; continue; } } if(q==1){ cout << setprecision(30); cout << p-(b-1) << endl; continue; } cout << setprecision(30); cout << min(p-(b-1),b-(q-1)) << endl; continue; } }