#include <bits/stdc++.h>
using namespace std;
int t;
long long r, g, b, k = 0;
long long a[4];
int main() {
  cin >> t;
  while (t--) {
    cin >> a[1] >> a[2] >> a[3];
    sort(a + 1, a + 1 + 3);
    k = a[1] + a[2];
    if (a[3] >= k)
      cout << k << endl;
    else {
      k -= a[3];
      r = min(a[1], k / 2) + a[3];
      cout << r << endl;
    }
  }
  return 0;
}
