#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
const ll infll = 1e18 + 3;
const int maxn = 1e6 + 77;
const int nmax = 1e6 + 577;
const ll basell = 1e18 + 3;
const ld eps = 1e-7;
const int inf = 1009000999;
const int nv = 100505;
const int baseint = 1000200013;
const ld PI = acos(-1.0);
inline bool EQ(ld a, ld b) { return fabs(a - b) < 1e-11; }
inline bool IF(int a, int b, int c) { return (a >= b && a <= c); }
inline bool IFS(int a, int b, int c) { return (a > b && a < c); }
template <typename T>
inline istream &operator>>(istream &_in, vector<T> &_v) {
  for (auto &_i : _v) {
    _in >> _i;
  }
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const vector<T> &_v) {
  if (_v.empty()) {
    return _out;
  }
  _out << _v.front();
  for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const pair<T, U> &_p) {
  _out << _p.first << ' ' << _p.second;
  return _out;
}
template <typename T, typename U>
inline istream &operator>>(istream &_in, pair<T, U> &_p) {
  _in >> _p.first >> _p.second;
  return _in;
}
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
int inline solve() {
  ios::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
  int T;
  cin >> T;
  while ((T--)) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b) swap(a, b);
    if (b > c) swap(b, c);
    if (a > c) swap(a, c);
    int k = 0;
    int t = 0;
    while (b > 0) {
      if (a == b && b == c) {
        if ((b % 2 == 1)) t++;
        b -= (b % 2 == 1);
        t += (b / 2) * 3;
        break;
      }
      if (a == 0) {
        t += (b);
        break;
      }
      if (a == b) {
        int d = min(c - b, min(a, c / 2));
        t += 2 * d;
        a -= d;
        b -= d;
        c -= 2 * d;
        if (a > b) swap(a, b);
        if (b > c) swap(b, c);
        if (a > c) swap(a, c);
        continue;
      }
      if (b == c) {
        int d = b - a;
        t += d;
        b -= d;
        c -= d;
        if (a > b) swap(a, b);
        if (b > c) swap(b, c);
        if (a > c) swap(a, c);
        continue;
      }
      k = (b - a);
      t += k;
      c -= k;
      b -= k;
      if (a == b && b == c) {
        if ((b % 2 == 1)) t++;
        b -= (b % 2 == 1);
        t += (b / 2) * 3;
        break;
      }
      if (a == b) {
        int d = min(c - b, min(a, c / 2));
        t += 2 * d;
        a -= d;
        b -= d;
        c -= 2 * d;
        if (a > b) swap(a, b);
        if (b > c) swap(b, c);
        if (a > c) swap(a, c);
        continue;
      }
      if (b == c) {
        int d = b - a;
        t += d;
        b -= d;
        c -= d;
        if (a > b) swap(a, b);
        if (b > c) swap(b, c);
        if (a > c) swap(a, c);
        continue;
      }
      if (b != 0) {
        t++;
        b--;
        c--;
      }
      if (a > b) swap(a, b);
      if (b > c) swap(b, c);
      if (a > c) swap(a, c);
    }
    cout << t << '\n';
  }
  return 0;
}
int32_t main() {
  solve();
  return 0;
}
