#include <bits/stdc++.h>
using namespace std;
int main() {
  long long tt;
  long long arr[5];
  cin >> tt;
  while (tt--) {
    cin >> arr[0] >> arr[1] >> arr[2];
    sort(arr, arr + 3);
    if (arr[2] <= arr[0] + arr[1]) {
      cout << (arr[0] + arr[1] + arr[2]) / 2 << endl;
      ;
    } else {
      cout << arr[0] + arr[1] << endl;
    }
  }
}
