#include <bits/stdc++.h>
using namespace std;
int ri() {
  int res = 0;
  char flag = 1, ch = getchar();
  while (ch != EOF && !isdigit(ch)) {
    flag = (ch == '-') ? -flag : flag;
    ch = getchar();
  }
  while (ch != EOF && isdigit(ch)) {
    res = res * 10 + (ch - '0');
    ch = getchar();
  }
  return res * flag;
}
long long rl() {
  long long res = 0;
  char flag = 1, ch = getchar();
  while (ch != EOF && !isdigit(ch)) {
    flag = (ch == '-') ? -flag : flag;
    ch = getchar();
  }
  while (ch != EOF && isdigit(ch)) {
    res = res * 10 + (ch - '0');
    ch = getchar();
  }
  return res * flag;
}
void wi(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x >= 10) wi(x / 10);
  putchar('0' + x % 10);
}
void wl(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x >= 10) wl(x / 10);
  putchar('0' + x % 10);
}
const int N = 105;
const int M = 5005 * 4;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const __int128 oone = 1;
const double eps = 1e-4;
const double pi = acos(-1);
namespace Solver {
int a[3];
void solve() {
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  if (a[2] > a[0] + a[1])
    cout << a[0] + a[1] << '\n';
  else
    cout << (a[0] + a[1] + a[2]) / 2 << '\n';
}
}  // namespace Solver
int main() {
  int t = 1;
  t = ri();
  for (int i = 1; i < t + 1; i++) {
    Solver::solve();
  }
  return 0;
}
