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