#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int A[3];
    int i, j, ans = 0;
    for (i = 0; i < 3; i++) cin >> A[i];
    sort(A, A + 3);
    if (A[1] + A[0] > A[2])
      cout << (A[0] + A[1] + A[2]) / 2 << endl;
    else
      cout << A[1] + A[0] << endl;
  }
  return 0;
}
