#include <bits/stdc++.h>
using namespace std;
int t, i, j, a[3];
long long ans;
bool cmp(int a, int b) { return a > b; }
int main() {
  cin >> t;
  for (i = 0; i < t; i++) {
    ans = 0;
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3, cmp);
    while (1) {
      if (a[1] == 0 || a[0] == a[2]) sort(a, a + 3, cmp);
      if (a[0] == a[1] && a[1] == a[2]) {
        if (a[0] % 2)
          ans += (a[0] / 2 * 3 + 1);
        else
          ans += (a[0] / 2 * 3);
        break;
      }
      if (a[1] == 0 && a[2] == 0) break;
      int xxx = min(a[1], a[0] - a[2]);
      a[1] -= xxx;
      a[0] -= xxx;
      ans += xxx;
    }
    cout << ans << endl;
  }
}
