#include <bits/stdc++.h>
using namespace std;
long long Q, n, l, r, c, i, j, a[200000], fir, sec;
long long f[200000];
long long ff[200000];
long long ans;
int main() {
  cin >> Q;
  while (Q--) {
    long long a[3];
    long long c, l, ans = 0, cur;
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    ans += a[0];
    cur = a[2] - a[1];
    cur = min(cur, a[0]);
    a[2] -= cur;
    a[0] -= cur;
    cur = a[0] / 2;
    a[2] -= a[0] - cur;
    a[1] -= cur;
    ans += min(a[2], a[1]);
    cout << ans << "\n";
  }
  return 0;
}
