#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline long long toLongLong(string s) {
  long long v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
inline vector<char> toVC(string s) {
  vector<char> data(s.begin(), s.end());
  return data;
}
template <typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
  in >> p.first >> p.second;
  return in;
}
template <typename T>
istream &operator>>(istream &in, vector<T> &v) {
  for (auto &x : v) in >> x;
  return in;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &out, const std::pair<T1, T2> &p) {
  out << "[" << p.first << ", " << p.second << "]"
      << "\n";
  return out;
}
template <class T>
void chmin(T &a, const T b) {
  a = min(a, b);
}
template <class T>
void chmax(T &a, const T b) {
  a = max(a, b);
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    vector<long long> a(3);
    cin >> a;
    sort((a).rbegin(), (a).rend());
    if (a[0] > a[1] + a[2]) {
      cout << a[1] + a[2] << endl;
    } else {
      cout << accumulate((a).begin(), (a).end(), 0LL) / 2 << endl;
    }
  }
}
