#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  while (n--) {
    long long ans = 0;
    long long a[3];
    for (int i = 0; i < 3; i++) cin >> a[i];
    sort(a, a + 3);
    cout << min(a[0] + a[1], (a[0] + a[1] + a[2]) / 2) << endl;
  }
}
