#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl
 
#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()
 
#define pb push_back
#define ff first
#define ss second
#define hell 1000000007
 
#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009
 
ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
ll a,b,c;
bool check(ll first,ll middle,ll last,ll num)
{
	if(num<first || num<middle || num<last)
	return 0;
	ll haha=first+middle+last-(3*num);
	haha*=-1;
	if(haha<b)
	return 0;
 
	//test1(haha);
	//test4(first,middle,last,num);
	return 1;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
        ll t;cin>>t;
	while(t--)
	{
		cin>>a>>b>>c;
		ll anss=hell;
		rep(a1,0,a+1)
		{
			rep(c1,0,c+1)
			{
				if(a1 && c1)
				continue;
 
				ll ans;
				ll first=a-a1;
				ll middle=a1+c1;
				ll last=c-c1;
		
				ll high=b+max(first,max(middle,last));
				ll low=min(first,min(middle,last));
				while(low<=high)
				{
					ll mid=(low+high)/2;
					if(check(first,middle,last,mid))
					{
						ans=mid;
						high=mid-1;
					}
					else
					low=mid+1;
				}
				anss=min(anss,ans);
			}
		}
		cout<<anss<<endl;
	}
}