#include <bits/stdc++.h>
using namespace std;
int T, I, n, i, x, m, a[250000];
int main() {
  cin >> T;
  for (I = 0; I < T; ++I) {
    int a[3], x;
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    x = a[0];
    if (a[0] + a[1] > a[2])
      cout << (a[0] + a[1] + a[2]) / 2;
    else
      cout << a[0] + a[1];
    cout << endl;
  }
  return 0;
}
