#include <bits/stdc++.h>
using namespace std;
int main() {
  long long test;
  cin >> test;
  while (test--) {
    vector<long long> v;
    for (int i = 0; i < 3; i++) {
      long long temp;
      cin >> temp;
      v.push_back(temp);
    }
    sort(v.begin(), v.end());
    if (v[0] + v[1] > v[2])
      cout << v[2] + ((v[0] + v[1]) - v[2]) / 2 << endl;
    else
      cout << v[0] + v[1] << endl;
  }
}
