#include <bits/stdc++.h>
using namespace std;
long long n, sum, num, sam, nam, a[4];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[1] >> a[2] >> a[3];
    sort(a + 1, a + 4);
    sum = 0;
    if (a[3] != a[2]) {
      sum += a[2] - a[1];
      a[3] -= a[2] - a[1];
      a[2] -= a[2] - a[1];
      sum += min(a[1], min(a[3] / 2, a[3] - a[2])) * 2;
      num = min(a[1], min(a[3] / 2, a[3] - a[2]));
      a[3] -= num * 2;
      a[1] -= num;
      a[2] -= num;
    } else if (a[3] == a[2] && a[1] != a[2]) {
      sum += a[2] - a[1];
      a[2] -= a[2] - a[1];
      a[3] -= a[3] - a[1];
    }
    if (a[3] == a[2] && a[2] == a[1]) {
      if (a[3] % 2 == 0) {
        sum += a[3] / 2 * 3;
      } else {
        sum += a[3] / 2 * 3 + 1;
      }
    }
    cout << sum << endl;
  }
}
