#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const long long infLL = 9000000000000000000;
int main() {
  int test;
  cin >> test;
  while (test--) {
    long long ans = 0;
    int n = 3;
    int arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];
    sort(arr, arr + n);
    if (arr[0] + arr[1] <= arr[2]) {
      ans = arr[0] + arr[1];
    } else {
      long long temp = arr[2] - arr[0] - arr[1];
      ans = arr[0] + arr[1];
      long long val = floor(temp / 2.0);
      ans += val;
    }
    cout << ans << '\n';
  }
  return 0;
}
