#include <bits/stdc++.h>
using namespace std;
vector<long long> v(3);
int main() {
  long long t;
  cin >> t;
  while (t--) {
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end());
    long long ans = min((v[0] + v[1] + v[2]) / 2, v[0] + v[1]);
    cout << ans << "\n";
  }
}
