#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    int v = a[0];
    int d = min(v, a[2] - a[1]);
    int ans = d;
    a[0] -= d;
    a[2] -= d;
    d = a[0] / 2 + a[0] % 2;
    a[2] = a[2] - d;
    a[1] = a[1] - a[0] / 2;
    ans += a[0];
    ans += min(a[1], a[2]);
    cout << ans << "\n";
  }
  return 0;
}
