#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int nax = 1e6 + 10;
vector<int> tree(4 * nax);
long long i, j, x, y, k, val;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long r, g, b;
    cin >> r >> g >> b;
    vector<long long> v;
    v.push_back(r), v.push_back(g), v.push_back(b);
    sort(v.begin(), v.end());
    if (v[2] >= v[1] + v[0])
      cout << v[1] + v[0] << endl;
    else
      cout << (v[0] + v[1] + v[2]) / 2 << endl;
  }
}
