#include <bits/stdc++.h>
using namespace std;
inline long long isqrt(long long k) {
  long long r = sqrt(k) + 1;
  while (r * r > k) r--;
  return r;
}
inline long long icbrt(long long k) {
  long long r = cbrt(k) + 1;
  while (r * r * r > k) r--;
  return r;
}
inline long long mnz(long long& a, long long b) { return a = (a > b ? b : a); }
inline long long mxz(long long& a, long long b) { return a = (a < b ? b : a); }
inline string toString(long long n) {
  stringstream ss;
  ss << n;
  return ss.str();
}
double const eps = 1e-6;
long long const Base = 1e9 + 7, oo = 1e17, MAXN = 1e6;
long long A[MAXN + 5];
long long Solves() {
  long long n, m, k, cnt = 0, ans = 0, x, y, q, c, sum = 0, v, t;
  n = 3;
  for (long long i = 1; i <= 3; i++) cin >> A[i];
  sort(A + 1, A + 1 + n);
  c = min(A[2], A[3]);
  long long l = 0, r = c, mid1, mid2;
  while (l <= r) {
    mid1 = (l + r) / 2;
    mid2 = mid1 + 1;
    v = mid1 + min(A[3] - mid1 + A[2] - mid1, A[1]);
    t = (mid2 > c ? -oo : mid2 + min(A[3] - mid2 + A[2] - mid2, A[1]));
    mxz(ans, max(v, t));
    if (v > t)
      r = mid1 - 1;
    else
      l = mid2 + 1;
  }
  cout << ans << endl;
  return 0;
}
int main() {
  if (fopen("locin.txt", "r")) freopen("locin.txt", "r", stdin);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long test = 1;
  cin >> test;
  for (long long T = 1; T <= test; T++) {
    Solves();
  }
}
