#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int a[3];
    for (long long int i = 0; i < 3; i++) cin >> a[i];
    long long int ans = 0;
    sort(a, a + 3);
    if (a[0] + a[1] <= a[2])
      ans = a[0] + a[1];
    else {
      long long int x = min(a[0], (a[0] + a[1] - a[2] + 1) / 2);
      ans += x;
      a[0] = a[0] - x;
      a[1] = a[1] - x;
      ans += min(a[2], a[0] + a[1]);
    }
    cout << ans << "\n";
  }
  return 0;
}
