#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define db(x) cout<<x<<" "<<endl;
#define _db(a,n) for(int i=1;i<=n;i++) cout<<a[i]<<" ";cout<<endl;
#define mem(a) memset(a,0, sizeof(a))
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l) for(int i=r;i>=l;i--)
void solve(){
int a,b,c;cin>>a>>b>>c;
if(c-a!=1){
cout<<"-1"<<endl;
return;
}
int x=0;
queue<int>q;
q.push(0);
while(q.size()){
x=q.front();
q.pop();
if(a){
a--;
q.push(x+1);
q.push(x+1);
}
else if(b){
b--;
q.push(x+1);
}
}
cout<<x<<endl;
}
signed main()
{
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;cin>>t;while(t--)
solve();
return 0;
}