#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.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];
    }
    sort(a, a + 3);
    if (a[2] <= a[0] + a[1]) {
      cout << (a[0] + a[1] + a[2]) / 2 << endl;
    } else
      cout << a[1] + a[0] << endl;
  }
  return 0;
}
