#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.141592653;
const long long mod = 1e9 + 7;
const long long N = 5e5 + 1;
const int big = 1e9 + 1;
const long long INF = 1e18 + 1;
int n, a[4];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[1] >> a[2] >> a[3];
    sort(a + 1, a + 4);
    if (a[3] <= a[1] + a[2])
      cout << (a[1] + a[2] + a[3]) / 2 << endl;
    else
      cout << a[1] + a[2] << endl;
  }
  return 0;
}
