#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void printv(vector<int> arr, int n) {
  for (int i = 0; i < n; ++i) cout << arr[i] << " ";
  cout << endl;
}
void print(int arr[], int n) {
  for (int i = 0; i < n; ++i) cout << arr[i] << " ";
  cout << endl;
}
bool isPrime(int n) {
  bool flag = 1;
  for (int i = 2; i <= sqrt(n); ++i) {
    if (n % i == 0) {
      flag = 0;
      break;
    }
  }
  return (flag ? 1 : 0);
}
int power(int x, int y) {
  int res = 1;
  while (y) {
    if (y & 1) res = (res * x) % 1000000007;
    x = (x * x) % 1000000007;
    y >>= 1;
  }
  return res;
}
void test_case() {
  int col[3];
  scanf("%d%d%d", &col[0], &col[1], &col[2]);
  sort(col, col + 3, greater<int>());
  if (col[0] - col[1] >= col[2]) {
    printf("%d\n", col[1] + col[2]);
  } else {
    int ans = (col[0] + col[1] - col[2]) / 2;
    printf("%d\n", ans + col[2]);
  }
}
signed main() {
  int t = 1;
  cin >> t;
  while (t--) test_case();
  return 0;
}
