#include <bits/stdc++.h>
using namespace std;
inline void setPrecision(int n) { cout.precision(n); }
long long int INF = 1e10;
int MOD = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if (a[2] >= (a[0] + a[1])) {
      cout << a[0] + a[1] << "\n";
    } else {
      cout << ((a[0] + a[1] + a[2]) >> 1) << "\n";
    }
  }
  return 0;
}
