#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    int x = a[0] + a[1] - a[2];
    if (x <= 0)
      cout << a[0] + a[1] << endl;
    else {
      int z = min(a[0], x / 2);
      cout << a[2] + z << endl;
    }
  }
  return 0;
}
