#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    vector<long long> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end(), greater<long long>());
    long long diff = a[0] - a[2];
    long long ans = 0;
    if (diff <= a[1]) {
      a[1] -= diff;
      a[0] -= diff;
      ans += diff;
      if (a[1] == 0)
        cout << ans + min(a[0], a[2]) << endl;
      else {
        if (a[1] % 2 == 0) {
          a[0] -= a[1] / 2;
          a[2] -= a[1] / 2;
          ans += a[1];
        } else {
          a[0] -= a[1] / 2;
          a[2] -= a[1] / 2;
          a[0]--;
          ans += a[1];
        }
        cout << ans + min(a[0], a[2]) << endl;
      }
    } else {
      diff = a[1];
      a[0] -= a[1];
      a[1] -= a[1];
      ans += diff;
      cout << ans + min(a[0], a[2]) << endl;
    }
  }
  return 0;
}
