#include <bits/stdc++.h>
using namespace std;
const long long Min = -1e4;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long input[3];
    long long sum = 0;
    for (long long i = 0; i <= 2; i++) cin >> input[i], sum += input[i];
    sort(input, input + 3);
    if (input[2] <= input[0] + input[1])
      cout << sum / 2 << endl;
    else {
      cout << sum - input[2] << endl;
    }
  }
}
