#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    vector<int> v;
    int r, g, b;
    cin >> r >> g >> b;
    v.push_back(r);
    v.push_back(g);
    v.push_back(b);
    sort(v.begin(), v.end());
    if (v[0] + v[1] <= v[2])
      cout << v[0] + v[1] << endl;
    else
      cout << (v[0] + v[1] + v[2]) / 2 << endl;
    v.clear();
  }
  return 0;
}
