#include <bits/stdc++.h>
using namespace std;
int main() {
  long int T;
  vector<long int> sweet(3);
  cin >> T;
  while (T--) {
    long int sum = 0;
    cin >> sweet[0] >> sweet[1] >> sweet[2];
    sort(sweet.begin(), sweet.end());
    sum = min((sweet[2] + sweet[1] + sweet[0]) / 2,
              (sweet[2] + sweet[1] + sweet[0]) - sweet[2]);
    cout << sum << endl;
  }
}
