#include<bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--) { int x,y,z; cin>>x>>y>>z; if(x+y>z&&x+y-z>z) cout<<x+y-z<<endl; else if(x+y==z) cout<<z+2<<endl; else cout<<-1<<endl; } return 0; }