#include <bits/stdc++.h>
using namespace std;
char buf[1 << 20], *p1, *p2;
template <typename T>
inline void read(T &t) {
  register int v =
      (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)
           ? EOF
           : *p1++);
  T f = 1;
  t = 0;
  while (!isdigit(v)) {
    if (v == '-') f = -1;
    v = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)
             ? EOF
             : *p1++);
  }
  while (isdigit(v)) {
    t = t * 10 + v - 48;
    v = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)
             ? EOF
             : *p1++);
  }
  t *= f;
}
template <typename T, typename... Args>
inline void read(T &t, Args &...args) {
  read(t);
  read(args...);
}
void solve() {
  int a[4];
  read(a[1], a[2], a[3]);
  sort(a + 1, a + 4);
  int ans = 0;
  if (a[3] >= a[1] + a[2]) {
    ans = a[1] + a[2];
  } else {
    ans = (a[1] + a[2] + a[3]) / 2;
  }
  printf("%d\n", ans);
}
signed main() {
  int T;
  read(T);
  while (T--) solve();
  return 0;
}
