#include <bits/stdc++.h>
using namespace std;
const int N = 500009;
const int mod = 1000000007;
long long int t;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> t;
  long long int r, g, b;
  while (t--) {
    long long int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if (a[2] > (a[0] + a[1])) {
      cout << (a[0] + a[1]) << "\n";
    } else {
      cout << (a[0] + a[1] + a[2]) / 2 << "\n";
    }
  }
  return 0;
}
