#include <iostream>
using namespace std;
int main() {
int tests;
cin>>tests;
while(tests--){
long long r,g,b, x,y,z, sum=0;
cin>>r>>g>>b;
if(r>=g) {
if(r>=b) {z=r; y=b;}
else {z=b; y=r;}
x=g;
}
else {
if(g>=b) {z=g; y=b;}
else {z=b; y=g;}
x=r;
}
if(z==y) {
sum+=x;
z=z-(x/2);
y=y-(x/2+x%2);
sum+=y;
}
else if((z-y)<x) {
sum+=(z-y);
x=x-(z-y);
z=y;
sum+=x;
z=z-(x/2);
y=y-(x/2+x%2);
sum+=y;
}
else {
sum+=(x+y);
}
cout<<sum<<"\n";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgogCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCWludCB0ZXN0czsKCWNpbj4+dGVzdHM7Cgl3aGlsZSh0ZXN0cy0tKXsKCSAgbG9uZyBsb25nIHIsZyxiLCB4LHkseiwgc3VtPTA7CgkgIGNpbj4+cj4+Zz4+YjsKCSAgaWYocj49ZykgewoJICAJaWYocj49Yikge3o9cjsgeT1iO30KCSAgCWVsc2Uge3o9YjsgeT1yO30KCSAgCXg9ZzsKCSAgfQoJICBlbHNlIHsKCSAgCWlmKGc+PWIpIHt6PWc7IHk9Yjt9CgkgIAllbHNlIHt6PWI7IHk9Zzt9CgkgIAl4PXI7CgkgIH0KCSAgaWYoej09eSkgewoJICAJc3VtKz14OwoJICAJej16LSh4LzIpOwoJICAJeT15LSh4LzIreCUyKTsKCSAgCXN1bSs9eTsKCSAgfQoJICBlbHNlIGlmKCh6LXkpPHgpIHsKCSAgCXN1bSs9KHoteSk7CgkgIAl4PXgtKHoteSk7CgkgIAl6PXk7CgkgIAlzdW0rPXg7CgkgIAl6PXotKHgvMik7CgkgIAl5PXktKHgvMit4JTIpOwoJICAJc3VtKz15OwoJICB9CgkgIGVsc2UgewoJICAJc3VtKz0oeCt5KTsKCSAgfQoJICBjb3V0PDxzdW08PCJcbiI7Cgl9CglyZXR1cm4gMDsKfQ==