#include <bits/stdc++.h>
using namespace std;
const long long N = 2e3 + 5;
const int32_t M = 998244353;
void solve() {
  long long a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  long long val2 = a[2] - a[1];
  if (val2 >= a[0]) {
    cout << a[1] + a[0] << "\n";
    return;
  }
  a[0] -= val2;
  long long val = a[0] / 2;
  cout << val2 + 2 * (val) + a[1] - val << "\n";
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  long long a = 1;
  while (t--) {
    solve();
    a += 1;
  }
}
