#include <bits/stdc++.h>
using namespace std;
namespace fastio {
template <class T>
istream& operator>>(istream& os, vector<T>& vec) {
  for (auto& u : vec) os >> u;
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
  for (auto& u : vec) os << u << " ";
  return os;
}
template <class T1, class T2>
inline istream& operator>>(istream& os, pair<T1, T2>& p) {
  return os >> p.first >> p.second;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  return os << p.first << " " << p.second;
}
template <class T>
ostream& operator<<(ostream& os, set<T>& con) {
  for (auto& u : con) os << u << " ";
  return os;
}
void re() {}
template <typename T, typename... args>
void re(T& x, args&... tail) {
  cin >> x;
  re(tail...);
}
void pr() {}
template <typename T>
void pr(const T& x) {
  cout << x;
}
template <typename T, typename... args>
void pr(const T& x, const args&... tail) {
  cout << x << " ";
  pr(tail...);
}
template <typename... args>
void prln(const args&... tail) {
  pr(tail...);
  cout << "\n";
}
}  // namespace fastio
using namespace fastio;
const long long int mod = 1e9 + 7;
const long long int mod1 = 998244353;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int arr[3];
    cin >> arr[0] >> arr[1] >> arr[2];
    sort(arr, arr + 3);
    if ((arr[0] + arr[1]) <= arr[2])
      prln(arr[0] + arr[1]);
    else {
      long long int sum = arr[2] - arr[1];
      arr[0] -= sum;
      arr[2] -= sum;
      arr[1] -= arr[0] / 2;
      arr[2] -= arr[0] / 2;
      if (arr[0] % 2) arr[2]--;
      sum += arr[0];
      sum += min(arr[1], arr[2]);
      prln(sum);
    }
  }
}
